pyrosm.get_data_by_geocoding

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, progress=None, headers=None, timeout=60, opener=None, strategy='single', must_cover=None, workers=None)#

Download (and by default crop) the OSM data for a geocoded place name.

Geocodes query (geocode()) and gets the data for the place as pyrosm.get_data_by_area() does: the smallest Geofabrik, BBBike or Movisda extract (or set of extracts) that covers it, downloaded and – by default – cropped to the place.

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 (its boundary polygon, or its box when the geocoder gives none) and return the cropped file, named after the query (e.g. area_brighton-and-hove-uk.osm.pbf) and used again while it and its extract are unchanged. When False, return the full extract.

  • download (bool) – When True (default), download the covering extract. When False, skip the download and return the PBF URL of the extract it would download instead (a list of URLs for a set of extracts).

  • update – As for pyrosm.get_data_by_area().

  • directory – As for pyrosm.get_data_by_area().

  • output_path (str, optional) – Path for the file pyrosm writes, as for pyrosm.get_data_by_area(). Ignored when download=False.

  • base_url (str) – The Nominatim base URL (see geocode()).

  • user_agent (str, optional) – The User-Agent header sent to Nominatim (see geocode()).

  • progress (bool | callable | None) – None (default) follows pyrosm.enable_logging(), which is True unless set. True shows the download as a bar on stderr, a widget in Jupyter when ipywidgets is installed (pip install "pyrosm[notebook]"); without a terminal, only a line naming the file is printed. False shows nothing. A callable is called as progress(written, total) after each chunk, with the bytes written so far and the file size, None when the server does not give it. The crop shows its progress the same way; a callable is then called with the percentage of the crop done.

  • headers – Network options for the geocoding request and for the requests of pyrosm.get_data_by_area().

  • timeout – Network options for the geocoding request and for the requests of pyrosm.get_data_by_area().

  • opener – Network options for the geocoding request and for the requests of pyrosm.get_data_by_area().

  • strategy – As for pyrosm.get_data_by_area().

  • must_cover – As for pyrosm.get_data_by_area().

  • workers – As for pyrosm.get_data_by_area().

Returns:

The cropped file path (default), the full extract path (crop=False), or the covering extract’s PBF URL (download=False; a list of URLs for a set of extracts).

Return type:

str | list