Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try using this:</p> <pre><code>topojson -o final.json -e data.tsv --id-property=code_2,code -p code_2,state=name -- topojson.json </code></pre> <p>Which should output:</p> <pre><code>{ "type": "Topology", "transform": { "scale": [ 0.000016880209206372492, 0.000007005401010148724 ], "translate": [ -1.8418800213354616, 51.15278777877789 ] }, "objects": { "states": { "type": "GeometryCollection", "geometries": [ { "type": "Polygon", "arcs": [ [ 0 ] ], "id": "AK", "properties": { "code_2": "AK", "state": "Alaska" } } ] } }, "arcs": [ [ [ 0, 588 ], [ 92, -294 ], [ 91, -294 ], [ -183, 588 ] ] ] } </code></pre> <p>From the <a href="https://github.com/mbostock/topojson/wiki/Command-Line-Reference">Command Line Reference wiki</a>:</p> <blockquote> <p><strong>--id-property</strong> name of feature property to promote to geometry id</p> </blockquote> <p>By using the <code>code_2</code> property with this option, you promote it as the feature ID.</p> <blockquote> <p>Prepend a <strong>+</strong> in front of the input property name to coerce its value to a number.</p> </blockquote> <p>Plus:</p> <blockquote> <p>If the properties referenced by <strong>--id-property</strong> are null or undefined, they are <strong>omitted</strong> from the output geometry object. Thus, the generated objects may not have a defined ID if the input features did not have a property with the specified name.</p> </blockquote> <p>So, when you are using <code>+code</code> and <code>+code_2</code>, they are probably <code>undefined</code>, as you can't convert the <code>AK</code> string value to a number.</p> <blockquote> <p>Here, the input property "FIPS" is coerced to a number and used as the feature identifier; likewise, the column named "FIPS" is used as the identifier in the CSV file. (If your CSV file uses a different column name for the feature identifier, you can specify multiple id properties, such as <code>--id-property=+FIPS,+id</code>.)</p> </blockquote> <p>That's why you have to add the <code>code</code> to the <code>--id-property=code_2,code</code> option. This is how the mapping is made (the <code>code_2</code> from <em>topojson.json</em> and the <code>code</code> column from <em>data.tsv</em>).</p> <blockquote> <p>Then, the output property "unemployment" is generated from the external data file, unemployment.tsv, which defines the input property "rate"</p> </blockquote> <p>In our case, <code>-p code_2,state=name</code> specifies that we will preserve the <code>code_2</code> property and we will rename the <code>name</code> property to <code>state</code>. The <strong>Properties</strong> and <strong>External Properties</strong> sections in the aforementioned documentation wiki are pretty informative on the matter.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload