Closed woodz- closed 6 years ago
This is the expected behavior. If you want features with properties, you need to put them on a properties object, as defined in the GeoJSON specification, section 3.2. geo2topo
does not propagate unknown fields.
That makes sense, thank you for the tip @mbostock
For me it's still misleading while I am referencing to your world-atlas. For my understanding, the properties
object is not explicitly generated in the topojson output and your clever established d.id
on the geojson's root will be gone like in my approach above.
Do you confirm or do I miss something here?
Anyways, my intent is to create a pull request and link it to here. You are welcome to reject it if I should have misunderstood the whole thing.
link to pull request of the world-atlas repo: ensure custom properties propagation
The world-atlas doesn’t include any properties. It only includes a unique identifier.
notes
geostitch
tooling and versions ├── d3-geo-projection@2.4.0 ├── ndjson-cli@0.3.1 ├── npm@3.10.10 ├── plugman@1.4.1 ├── shapefile@0.6.6 ├── topojson-server@3.0.0 └── topojson-simplify@3.0.2
$ node --version: v6.11.2
reproduce
$ shp2json -n "./ne_10m_admin_0_countries.shp" > "ne_10m_admin_0_countries-ndjson.geojson"
$ ndjson-map 'i = d.properties.ISO_A3, d.iso = i === "-99" ? undefined : i, i = d.properties.NAME_LONG, d.name = i === "-99" ? undefined : i, delete d.properties, d' < "ne_10m_admin_0_countries-ndjson.geojson" > "ne_10m_admin_0_countries_country_codes.json"
$ geo2topo -q 1e5 -n countries="./ne_10m_admin_0_countries_country_codes.json" > "./ne_10m_admin_0_countries.topojson"
if you then look into "ne_10m_admin_0_countries.topojson", you should see the properties
"iso"
and"name"
are gone, against many tutorials on the internet like this: medium, while they are in "ne_10m_admin_0_countries_country_codes.json"could anybody confirm and maybe explain why this is happening?
here is a rather old sof discussion