pyrosm.get_data_by_geocoding#
- pyrosm.get_data_by_geocoding(query, crop=True, download=True, update=False, directory=None, output_path=None, base_url='https://nominatim.openstreetmap.org', user_agent=None)#
Download (and by default crop) the OSM data for a geocoded place name.
Geocodes
query(geocode()), finds the smallest Geofabrik extract that covers it, downloads it, and – by default – crops it to the place before returning the cropped file path.- Parameters:
query (str) – The place name to look up, e.g.
"Brighton and Hove, UK".crop (bool) – When
True(default), crop the downloaded extract to the place and return the cropped file, named after the query (e.g.brighton-and-hove-uk.osm.pbf). WhenFalse, return the full extract.download (bool) – When
True(default), download the covering extract. WhenFalse, skip the download and return the covering extract’s PBF URL instead.update (bool) – When
True, re-download the extract even if it already exists locally.directory (str, optional) – Directory to download into / write the cropped file to.
None(default) uses a pyrosm temp directory.output_path (str, optional) – Path for the cropped file when
crop=True(overrides the automatic name). Ignored whencrop=Falseordownload=False.base_url (str) – The Nominatim base URL (see
geocode()).user_agent (str, optional) – The
User-Agentheader sent to Nominatim (seegeocode()).
- Returns:
The cropped file path (default), the full extract path (
crop=False), or the covering extract’s PBF URL (download=False).- Return type:
str