Tool for mapping locations based on JSON input file.
# download map data
mkdir data
cd data/
wget 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip'
unzip ne_110m_admin_0_countries.zip
# install tools
npm install -g shapefile
npm install -g topojson
npm install -g ndjson-cli
Convert binary .shp file to human readable newline-delimted GeoJSON so it's easier to work with from the command line:
shp2json ne_110m_admin_0_countries.shp | ndjson-split 'd.features' > countries.ndjson
Extract the fields we need:
cat countries.ndjson | ndjson-map '{type: d.type, properties: {name: d.properties.name, iso_code: d.properties.iso_a2, scalerank: d.properties.scalerank}, geometry: d.geometry}' > countries_min.ndjson
Filter out Antarctica
cat countries_min.ndjson | ndjson-filter 'd.properties.iso_code != "AQ"' > countries_min_fil.ndjson
Convert to TopoJSON to reduce file size
geo2topo -n countries_min_fil.ndjson > countries_topo.json