Skip to content

Instantly share code, notes, and snippets.

@lukasmartinelli
Created April 26, 2016 14:20
Show Gist options
  • Save lukasmartinelli/6ce5043d00cf0c731ce83ed9429fe897 to your computer and use it in GitHub Desktop.
Save lukasmartinelli/6ce5043d00cf0c731ce83ed9429fe897 to your computer and use it in GitHub Desktop.
Extract city bounding box CSV from Mapzen
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