block by hugolpz 358d785b6ae94c34dd29

Wikiatlas — administrative layer

Full Screen

Makefile

Action: When run, this administrative.makefile download administrative L0 (countries), L1 (subunits), and cities (places) GIS sources, process them (unzip, crop, filter), to output an elegant composite stack of your target L1 district upon L0 backgrounds, as topojson and WP styled SVG files.

Output:

Direct command:

make -f administrative.makefile ITEM=India WEST=67.0 NORTH=37.5  EAST=99.0 SOUTH=05.0 SELECTOR_L1="admin IN ('INDIA')"

Parameters:

Derivated from ogr2ogr and topojson.js.

[1]: If not there, the download task will automatically download the NaturalEarth countries, subunits, and places archive files totaling about 30MB. This may take from few minutes.

See also:

Suggestions? Drop me a suggestion/command line @hugo_lz

index.html


<!DOCTYPE html>
<meta charset='utf-8'>
<style>
  /* Style here... */
  path#IND {
    fill: none;
    stroke: #000;
  }
  image.bg {
    opacity: 0.2;
  }
  #legend, #image { border: .2em solid #C0C0C0; background: #EFEFEF; margin: 1em 8em 1em 8em; padding:0.5em; box-shadow: .1em .2em .2em .1em grey ; }
  a { color: #0b5b0c;}

  .code { color: white; background: #333; border: 2px solid #C0C0C0; padding: 0.4em;font-weight: 900; }
  .code:first-letter { font-size:1.5em;color: #0b5b0c; }
  iframe { font-size: 0.8em;}
</style>


<div id="legend" align="center" width="60%">
  <big><p><b>administrative data</b> for administrative maps (aka <b>*_location_map.ext</b> on wikipedia) generated by single command:</p></big>
  <small>
    <p class="code">$make -f administrative.makefile ITEM=India WEST=67.0 NORTH=37.5  EAST=99.0 SOUTH=05.0</p>
  <p>Short log of past 2 weeks <a href="//twitter.com/wikiatlas">Wikimaps Atlas</a> administrative layer's trials-and-errors explorations.</p>
  <p>All is generated from <i>A-to-Z</i> via command lines and <a href="//bl.ocks.org/hugolpz/358d785b6ae94c34dd29#administrative.makefile">a single makefile</a>. Some dependencies required.</p>
  <p>You can upload and check your topojson at the <a href="//hugolpz.github.io/distillery/">WikiAtlas distillery</a>.</a> Follow <a href="//twitter.com/wikiatlas">@WikiAtlas</a>/<a href="//twitter.com/hugo_lz">Hugo_lz</a>.</p></small>
</div>
<div id="image" align="center" width="60%" height="900px">
  <iframe width="100%" height="600px" src="//hugolpz.github.io/distillery/"></iframe>
<!--  <img src="./Wikiatlas_distillery_topojson_preview.png" href="./Wikiatlas_distillery_topojson_preview.png" width="60%"></img>-->
</div>

administrative.makefile

#DEFAULT VALUES (customizable):
# inherit ITEM, WEST, NORTH, EAST, SOUTH from master.makefile.
SELECTOR_POP_MIN=200000
SELECTOR_L1=admin IN ('$(ITEM)')
SELECTOR_PLACES=ADM0NAME = '$(ITEM)' AND POP_MAX > '$(SELECTOR_POP_MIN)'
QUANTIZATION=1e4

#MAKEFILE
topojson: geojson_filters
	topojson \
		-q $(QUANTIZATION) \
		-o $(ITEM).administrative.topo.json \
		-- admin_0=countries.geo.json admin_1=subunits.geo.json places=places.geo.json

geojson_filters: crop unzip
	ogr2ogr -f GeoJSON \
		countries.geo.json \
		crop_L0.shp
	ogr2ogr -f GeoJSON -where "$(SELECTOR_L1)" \
		subunits.geo.json \
		ne_10m_admin_1_states_provinces.shp
	ogr2ogr -f GeoJSON -where "$(SELECTOR_PLACES)" \
		places.geo.json \
		ne_10m_populated_places.shp
#or "iso_a2 = 'AT' AND SCALERANK < 20" , see also sr_adm0_a3
#ADM0NAME = 'Egypt' OR ADM0NAME = 'Iran' OR SOV0NAME = 'Saudi Arabia' OR SOV0NAME = 'Lebanon' OR SOV0NAME = 'Turkey' OR SOV0NAME = 'Syria' OR SOV0NAME = 'Iraq' OR ISO_A2 = 'noFR'

crop: unzip touch
	ogr2ogr -clipsrc $(WEST) $(NORTH) $(EAST) $(SOUTH) crop_L0.shp ne_10m_admin_0_countries.shp
	# WNES coordinates        

#unzip -n : no overwrite
unzip: downloads 
	unzip -n ../data/NE/countries.zip 
	unzip -n ../data/NE/subunits.zip
	unzip -n ../data/NE/places.zip
touch: unzip
	touch ne_10m_admin_0_countries.shp
	touch ne_10m_admin_1_states_provinces.shp
	touch ne_10m_populated_places.shp

downloads: clean d0 d1 d2 d3
	# downloads done.

d0:
	mkdir -p ../data/NE/
d1:
	curl  \
		-o ../data/NE/countries.zip \
		-L -C - 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip'
	## http://www.nacis.org/naturalearth/10m/cultural/NE_10m_admin_0_map_subunits.zip
d2:
	curl \
		-L -C - 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_1_states_provinces.zip' \
		-o ../data/NE/subunits.zip 
d3:
	curl \
		-L -C - 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip' \
		-o ../data/NE/places.zip	

clean:
	rm -f *.json
	rm -f *.dbf
	rm -f *.prj 
	rm -f *.shp
	rm -f *.shx
	rm -f *.html
	rm -f *.txt