I grabbed a KML
file of UK counties. I then headed over to this other website to convert the KML
to GeoJSON
.
All smooth so far. Then I wanted to convert the GeoJSON
to its sibling format TopoJSON
via the NodeJS package topojson.
So I ran the following command:
topojson -o topo-uk-map.json uk-map.json
This worked in the sense that the conversion took place, but in the process I lost all the names of the counties!!
How do I edit the command above so that the name of the counties remain in place? I looked through the documentation for topojson but could not find anything that would help me, either the info is not there, or the docs are not n00b friendly at all.
Use the -p
parameter. From the Wiki (which i think is quite good actually):
-p, --properties feature properties to preserve; no name preserves all properties
To retain some properties and rename them:
topojson -p newpropertyname=inputpropertyname -- input.geojson -o outpu.topojson
Note: topojson also accept .shp as input, which can ease your terminal work.
See: https://github.com/mbostock/topojson/wiki/Command-Line-Reference#properties