This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f85124e
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"layers": [{ | ||
"id": "context", | ||
"src": "shp/ne_50m_admin_0_countries.shp", | ||
"simplify": 1.5 | ||
},{ | ||
"id": "regions", | ||
"src": "shp/ne_10m_admin_1_states_provinces_shp.shp", | ||
"attributes": [{ | ||
"src": "ISO", "tgt": "iso3" | ||
},"NAME_1","FIPS_1"], | ||
"filter": ["ISO","=","DEU"], | ||
"styles": { | ||
"fill": "red", | ||
"fill-opacity": 0.35 | ||
}, | ||
"simplify": 1.2 | ||
}], | ||
"bounds": { | ||
"mode": "polygon", | ||
"data": { | ||
"layer": "regions" | ||
}, | ||
"padding": 0.06 | ||
}, | ||
"export": { | ||
"height": 300, | ||
"round": 1, | ||
"ratio": 1.5 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
|
||
from kartograph import Kartograph as Kartograph | ||
import shapefile | ||
import json | ||
import os.path | ||
|
||
map_output_dir = 'maps/' | ||
|
||
country_min_area = { | ||
'JPN': .1, | ||
'AUS': .01, | ||
'CAN': .05, | ||
'ALA': .1, | ||
'FRA': .2, | ||
'DNK': .1, | ||
'ITA': .05, | ||
'GBR': .165, | ||
'ESP': .165 | ||
} | ||
|
||
custom_country_center = { | ||
'USA': (-98.606, 39.622) | ||
} | ||
|
||
# extract admin codes from shapefile, sorted by population | ||
records = shapefile.Reader('shp/ne_50m_admin_0_countries.shp').records() | ||
records = sorted(records, key=lambda rec: rec[23] * -1) | ||
adm_codes = [rec[9] for rec in records] | ||
|
||
K = Kartograph() | ||
|
||
for adm_code in adm_codes: | ||
map_filename = map_output_dir + adm_code + '.svg' | ||
if not os.path.exists(map_filename): | ||
tmpl = json.loads(open('country-template.json').read()) | ||
tmpl['layers'][1]['filter'][2] = adm_code | ||
print adm_code | ||
try: | ||
K.generate(tmpl, map_filename, preview=False) | ||
except: | ||
print 'error!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.shp | ||
*.dbf | ||
*.shx | ||
*.sbx | ||
*.sbn | ||
*.prj | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/50m-admin-0-countries.zip | ||
unzip -d . 50m-admin-0-countries.zip | ||
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/50m-lakes.zip | ||
unzip -d . 50m-lakes.zip | ||
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/10m-admin-1-states-provinces-shp.zip | ||
unzip -d . 10m-admin-1-states-provinces-shp.zip |