3535)
3636
3737
38- def nominatim_osm (query : str , expected_position = 0 ) -> GeoDataFrame :
38+ def nominatim_osm (query : str , expected_position : "int | None" = 0 ) -> GeoDataFrame :
3939 """
4040 Download OpenStreetMaps data for a specific city.
4141
4242 Parameters
4343 ----------
4444 query: str
45- Query for city polygon data to be downloaded.
45+ Query string for OSM data to be downloaded (e.g. "Lima, Peru") .
4646 expected_position: int 0:n
4747 Expected position of the polygon data within the Nominatim results.
48- Default 0 (first result).
48+ Default 0 returns the first result.
49+ If set to None, all the results are returned.
4950
5051 Returns
5152 -------
52- city : GeoDataFrame
53- GeoDataFrame with the city's polygon as its geometry column .
53+ gdf : GeoDataFrame
54+ GeoDataFrame with the fetched OSM data .
5455
5556 Examples
5657 --------
@@ -66,9 +67,10 @@ def nominatim_osm(query: str, expected_position=0) -> GeoDataFrame:
6667 response = requests .get (osm_url , params = osm_parameters )
6768 all_results = response .json ()
6869 gdf = gpd .GeoDataFrame .from_features (all_results ["features" ], crs = "EPSG:4326" )
69- city = gdf .iloc [expected_position : expected_position + 1 , :]
70-
71- return city
70+ if expected_position is None :
71+ return gdf
72+
73+ return gdf .iloc [expected_position : expected_position + 1 ]
7274
7375
7476def overpass_pois (bounds , facilities = None , custom_query = None ):
0 commit comments