pyrosm.get_data_by_bbox#
- pyrosm.get_data_by_bbox(bbox, crop=True, download=True, update=False, directory=None, output_path=None)#
Download (and by default crop) the OSM data covering a bounding box.
Finds the smallest Geofabrik extract whose extent fully covers
bbox, downloads it, and – by default – crops it tobboxbefore returning the cropped file path.- 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 tobboxand return the cropped file, namedbbox_<minx>_<miny>_<maxx>_<maxy>.osm.pbf. WhenFalse, return the full downloaded 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.
- Returns:
The cropped file path (default), the full extract path (
crop=False), or the covering extract’s PBF URL (download=False).- Return type:
str
- Raises:
ValueError – If no single extract fully covers
bbox.