API Reference#
TinyOSM: Fetch OpenStreetMap data for a bounding box.
OverpassError #
OSMFilters #
Predefined Overpass QL tag-filter strings for :func:fetch.
Each attribute is a valid osm_filter value — either a single string
or a tuple of strings (which :func:fetch issues as separate queries
and merges into one FeatureCollection). Any other Overpass QL tag-filter
string works too.
configure_logger #
configure_logger(
*,
verbose=None,
level=None,
file=None,
file_level=None,
file_mode="a",
file_only=False,
)
Configure logging settings.
Parameters:
-
verbose(bool, default:None) –Shortcut:
Truesets console to DEBUG,Falseto WARNING. If bothlevelandverboseare given,levelwins. -
level(str or int, default:None) –Console logging level (
"DEBUG","INFO","WARNING", etc.). -
file(str or Path, default:None) –Enable file logging at this path. Pass
Noneto disable file logging. -
file_level(str or int, default:None) –File handler level. Defaults to
DEBUG. -
file_mode(('a', 'w'), default:'a') –Append or overwrite the log file. Defaults to
'a'. -
file_only(bool, default:False) –If
True, disable console logging. Requiresfileto be set.
fetch #
Fetch OSM data within a bounding box as a GeoJSON FeatureCollection.
Large bounding boxes are automatically subdivided into tiles and fetched
across rotating Overpass mirrors with retries. The response is returned
as a valid GeoJSON FeatureCollection dict that can be fed directly
to geopandas with no post-processing.
Parameters:
-
left(float) –Bounding box coordinates in WGS84 (EPSG:4326).
-
bottom(float) –Bounding box coordinates in WGS84 (EPSG:4326).
-
right(float) –Bounding box coordinates in WGS84 (EPSG:4326).
-
top(float) –Bounding box coordinates in WGS84 (EPSG:4326).
-
osm_filter(str or sequence of str) –Overpass QL tag-filter string(s) selecting which features to fetch. Use a member of :class:
OSMFiltersfor the built-in presets (OSMFilters.HIGHWAY,OSMFilters.WATERWAY,OSMFilters.WATER_BODY) or pass any valid Overpass QL tag-filter (e.g.'["amenity"="restaurant"]'). When a sequence is given, each filter is queried separately and the results are merged into a single deduplicated FeatureCollection.
Returns:
-
dict[str, Any]–A GeoJSON FeatureCollection dict —
{"type": "FeatureCollection", "features": [...]}— where every feature has anosm_typeandosm_idin itspropertiesalongside the OSM tags.
Raises:
-
ValueError–If the bounding box is invalid.
-
OverpassError–If all Overpass mirrors fail to return a response.
Examples:
Fetch highway features using a preset:
>>> import geopandas as gpd
>>> fc = fetch(-97.75, 30.25, -97.70, 30.30, osm_filter=OSMFilters.HIGHWAY)
>>> gdf = gpd.GeoDataFrame.from_features(fc, crs=4326)
Fetch with a custom Overpass filter: