
Scraping OpenStreetMap: Geographic and POI Data at Scale
Scraping OpenStreetMap: Geographic and POI Data at Scale OpenStreetMap (OSM) is the world's largest open geographic database — a Wikipedia for maps. With data on roads, buildings, and POIs for the entire planet, it's invaluable for location-based apps. Completely free and open. Overpass API import requests , json , time from datetime import datetime class OSMScraper : OVERPASS = " http://overpass-api.de/api/interpreter " NOMINATIM = " https://nominatim.openstreetmap.org " def __init__ ( self ): self . session = requests . Session () self . session . headers . update ({ ' User-Agent ' : ' OSMCollector/1.0 ' }) def query ( self , q , timeout = 60 ): return self . session . post ( self . OVERPASS , data = { ' data ' : q }, timeout = timeout ). json () def pois_in_bbox ( self , bbox , amenity ): s , w , n , e = bbox q = f ''' [out:json][timeout:60]; (node[ " amenity " = " { amenity } " ]( { s } , { w } , { n } , { e } ); way[ " amenity " = " { amenity } " ]( { s } , { w } , { n } , { e } )
Continue reading on Dev.to Tutorial
Opens in a new tab



![[MM’s] Boot Notes — The Day Zero Blueprint — Test Smarter on Day One](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1368%2F1*AvVpFzkFJBm-xns4niPLAA.png&w=1200&q=75)