Skip to content

thomasmarkrea/Mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapper

Tool for mapping locations based on JSON input file.

Manipulating Shape Files

Download Data

# 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

# install tools
npm install -g shapefile
npm install -g topojson
npm install -g ndjson-cli

Manipulate Data

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

About

Highlight countries based on json file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published