pyrosm.get_data_by_bbox

pyrosm.get_data_by_bbox#

pyrosm.get_data_by_bbox(bbox, crop=True, download=True, update=False, directory=None, output_path=None, progress=None, headers=None, timeout=60, opener=None, strategy='single', must_cover=None, workers=None)#

Download (and by default crop) the OSM data covering a bounding box.

Gets the data for the box 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 box.

Parameters:
  • bbox (list | tuple | numpy.ndarray | shapely geometry | GeoDataFrame | GeoSeries) – The area of interest as [minx, miny, maxx, maxy] in lon/lat, a Shapely geometry (its bounding box is used), or a GeoDataFrame/GeoSeries (its total bounds are used).

  • crop (bool) – When True (default), crop the downloaded extract to bbox and return the cropped file, named bbox_<minx>_<miny>_<maxx>_<maxy>.osm.pbf and used again while it and its extract are unchanged. When False, return the full downloaded 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.

  • 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 – As for pyrosm.get_data_by_area().

  • timeout – As for pyrosm.get_data_by_area().

  • opener – As for 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

Raises:

ValueError – If bbox is not a usable box, or no extract covers it (ExtractNotFoundError).