Last active
May 1, 2018 10:28
-
-
Save Mazur93/078cb7da9c8a55bca3f9e1187839811c to your computer and use it in GitHub Desktop.
Here is a simple python 3 script that downloads all OSM data within a given bounding box via the overpass API
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
# author: Bartosz Mazurkiewicz | |
# Downloading OSM data via the overpass API with python3. Pay attention to not generate that much traffic. | |
# The servers are for everyone and the resources are limited. See the usage policy at http://wiki.openstreetmap.org/wiki/Overpass_API | |
import time | |
import os | |
import urllib.request | |
# Bounding box - example Florence, Italy | |
north = str(43.8) | |
south = str(43.75) | |
east = str(11.3) | |
west = str(11.2) | |
# bbox=west,south,east,north | |
url = 'http://www.overpass-api.de/api/map?bbox=' + west + ',' + south + ',' + east + ',' + north | |
# Download osm data and print download time | |
start = time.time() | |
urllib.request.urlretrieve(url, 'DataOSM.osm') | |
end = time.time() | |
print("Download OSM data took " + str(end-start) + " seconds") | |
print("Data size is about " + str(os.path.getsize(os.path.join(os.getcwd(), "DataOSM.osm"))/1000000) + " mb") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment