Skip to content

Instantly share code, notes, and snippets.

@napo
Last active January 27, 2024 11:23
Show Gist options
  • Save napo/dfb80d0d0e31d8195ed8bd73d6d9c1f4 to your computer and use it in GitHub Desktop.
Save napo/dfb80d0d0e31d8195ed8bd73d6d9c1f4 to your computer and use it in GitHub Desktop.
import urllib
import json
file_url = 'https://api.datawrapper.de/v3/basemaps/rome-zip'
file_json = "rome.json"
file_output = "rome.topojson"
urllib.request.urlretrieve(file_url ,file_json)
with open(file_json, 'r') as f:
json_data = json.load(f)
topojson = dict(json_data["content"])
with open(file_output, 'w') as f:
json.dump(topojson, f)
@napo
Copy link
Author

napo commented Jan 27, 2024

a simple script to extract the topojson from the datawrapper API
In the example the zip codes geometries of Rome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment