From 02119cc5f2ceb153d19882931c376946140cf11f Mon Sep 17 00:00:00 2001 From: Brad Oyler Date: Mon, 19 Sep 2016 11:36:58 -0400 Subject: [PATCH] adds world-coutries target --- Makefile | 7 +++++- README.md | 2 +- world-countries/Makefile | 53 +++++++++++++++++++++++++++++++++++++++ world-countries/README.md | 13 ++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 world-countries/Makefile create mode 100644 world-countries/README.md diff --git a/Makefile b/Makefile index abed1c5..62830ca 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ # Atlas-make - master makefile -TARGETS=na-places us-demographics us-towns us-cities us-states us-counties us-transportation us-congress +TARGETS=na-places us-demographics us-towns us-cities us-states us-counties us-transportation us-congress world-countries all: ${TARGETS} .PHONY: ${TARGETS} +world-countries: + cd $@ && make all + na-places: cd $@ && make all @@ -39,6 +42,7 @@ us-transportation: us-congress: cd $@ && make all + ##-- deletes all files except gz/zip files ----- clean-all: cd na-places && make clean-all @@ -49,3 +53,4 @@ clean-all: cd us-counties && make clean-all cd us-transportation && make clean-all cd us-congress && make clean-all + cd world-countries && make clean-all diff --git a/README.md b/README.md index 2275521..155786f 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ this may take about 15mins, so try `$ make us-states` first ### Future plans: - expand `us-demographics` data (Census & ACS) - recipes for inserting data into PostgreSQL -- a `world-countries` target +- more `world-*` targets - more map layers: roads, airports, etc. - rendered map examples using [D3.js](https://d3js.org/) & [D3-Node](https://github.com/bradoyler/d3-node) diff --git a/world-countries/Makefile b/world-countries/Makefile new file mode 100644 index 0000000..27f75bd --- /dev/null +++ b/world-countries/Makefile @@ -0,0 +1,53 @@ +# http://www.naturalearthdata.com/downloads/ +# SCALES: 10m 50m 110m +BIN = ../node_modules/.bin +NATURAL_EARTH_CDN = http://naciscdn.org/naturalearth + +all: topo/world-110m.json csv/world-countries.csv + +.SECONDARY: + +gz/ne_10m_%.zip: + mkdir -p $(dir $@) + curl "$(NATURAL_EARTH_CDN)/10m/cultural/ne_10m_$*.zip" -o $@.download + mv $@.download $@ + +gz/ne_50m_%.zip: + mkdir -p $(dir $@) + curl "$(NATURAL_EARTH_CDN)/50m/cultural/ne_50m_$*.zip" -o $@.download + mv $@.download $@ + +gz/ne_110m_%.zip: + mkdir -p $(dir $@) + curl "$(NATURAL_EARTH_CDN)/110m/cultural/ne_110m_$*.zip" -o $@.download + mv $@.download $@ + +# Admin 0 – countries (5.08M) +shp/ne_%_admin_0_countries.shp: gz/ne_%_admin_0_countries.zip + mkdir -p $(dir $@) + unzip -d shp $< + touch $@ + +# created w/ basic props, countries & land collection +topo/world-%.json: shp/ne_%_admin_0_countries.shp + mkdir -p $(dir $@) + $(BIN)/topojson \ + --quantization 1e5 \ + --properties name,type,abbrev,postal,pop_est,continent \ + --id-property=+iso_n3 \ + -- countries=shp/ne_$*_admin_0_countries.shp \ + | $(BIN)/topojson-merge \ + -o $@ \ + --io=countries \ + --oo=land \ + --no-key + +csv/world-countries.csv: shp/ne_110m_admin_0_countries.shp + mkdir -p $(dir $@) + rm -f $@ + ogr2ogr -f 'CSV' -progress $@ $< + +clean-all: clean/shp clean/topo clean/csv + +clean/%: + rm -rf $(notdir $@) diff --git a/world-countries/README.md b/world-countries/README.md new file mode 100644 index 0000000..2fab30e --- /dev/null +++ b/world-countries/README.md @@ -0,0 +1,13 @@ +# World-Countries + +Builds Shape, TopoJson & CSV files for all countries. + +Data files are built from [Small](http://www.naturalearthdata.com/downloads/10m-cultural-vectors/), [Medium](http://www.naturalearthdata.com/downloads/50m-cultural-vectors/) & [Large](http://www.naturalearthdata.com/downloads/110m-cultural-vectors/) scale Cultural vectors from [Natural Earth](http://naturalearthdata.com/) + + +### Medium scale (1:50m) +`$ make topo/world-50m.json` +![50m-world](https://cloud.githubusercontent.com/assets/425966/18637913/12d2d6d6-7e5c-11e6-93a3-7f3d392c836f.png) + +### Zoomed, showing data +![50m-world-zoomed](https://cloud.githubusercontent.com/assets/425966/18637669/2d8d6abe-7e5b-11e6-98c2-ab357fd405ef.png)