Geohunter.osm

geohunter.osm

This module wraps requests to OpenStreetMap’s Overpass API with an interface for the GeoPandas data structures. The OpenStreetMap has a data model based on nodes, ways and relations. The geometric data structures available in geopandas are points, lines and polygons (but also multipoints, multilines and multipolygons).

For a complete list of data categories available (“map features”), please look the OpenStreetMap.

class geohunter.osm.Eagle

Bases: object

Eagle is the facade for requesting data given the map keys available with the request_overpass() method. This class also implements a get() method which return the data required in a single pandas DataFrame that has a geometric attribute that makes it a geopandas GeoDataFrame (please consult geopandas documentation for more details).

close()
debug__find_geom_not_being_successfully_parsed(bbox, key, item)
get(*args, **kwargs)
request_overpass(bbox, map_feature_key, map_feature_item)

Return the json resulted from a single request on Overpass API.

It generates the Overpass QL query from the map features defined, including nodes, ways and relations, and request data from the API. Please consult OpenStreetMap documentation (https://wiki.openstreetmap.org/wiki/Map_Features) for a full list of map features available.

Parameters:
  • bbox (str or geopandas.GeoDataFrame) – If str, follow the structure (south_lat,west_lon,north_lat,east_lon), but if you prefer to pass a geopandas.GeoDataFrame, the bbox will be defined as the maximum and minimum values delimited by the geometry.
  • map_feature_key (str) – Map key item from OpenStreetMap, such as “amenity”, “highway” etc.
  • map_feature_item (str) –
Returns:

Data requested in output format of Overpass API.

Return type:

dict

geohunter.osm.overpass_result_to_geodf(result, as_points=False)

Transforms the result from Overpass request to GeoDataFrame.

geohunter.osm.parse_geometry(x_elements_df)

Transforms coordinates into shapely objects.

geohunter.osm.parse_relation(x_members)

Transforms coordinates of ‘relation’ objects into shapely objects.

geohunter.osm.requests_retry_session(retries=3, backoff_factor=0.5, session=None, status_forcelist=(500, 503, 502, 504))
geohunter.osm.timelog(func)