Created
April 26, 2016 14:20
-
-
Save lukasmartinelli/6ce5043d00cf0c731ce83ed9429fe897 to your computer and use it in GitHub Desktop.
Extract city bounding box CSV from Mapzen
This file contains hidden or 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
import json | |
doc = json.load(open('cities.json')) | |
for region, region_obj in doc['regions'].items(): | |
for city_name, city_obj in region_obj['cities'].items(): | |
bbox = city_obj['bbox'] | |
parts = city_name.split('_') | |
if len(parts) != 2: | |
continue | |
city, country = parts | |
print('\t'.join([ | |
city_name + '.mbtiles', | |
country, | |
city, | |
bbox['top'], | |
bbox['left'], | |
bbox['bottom'], | |
bbox['right'], | |
])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment