Duc Anh Ho
Duc Anh Ho

Reputation: 21

how to get Bounding Box values of a region using Osmnx?

I'm working right now with Osmnx and already captured and plotted a city like this code:

import osmnx as ox

city = "Hannover Mitte"
buildings = ox.geometries_from_place(query=city, tags={'building':True})
...

City I would like to get min-max values from Longtitude and Lattitude of this city by using Osmnx to create bbox of city. Osmnx provides the function osmnx.utils_geo.bbox_from_point to get Bbox from a region created by a point, but I don't know if there is a function to get bbox from the whole city like that, or how to get the min max values of long and Lattitude (Which already displayed in the above figure). Does someone have a solution for my question? Thank you in Advance!

Upvotes: 0

Views: 1645

Answers (1)

JoScratcherJo
JoScratcherJo

Reputation: 100

buildings in your case is a geodataframe, take a look here: https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.total_bounds.html?highlight=GeoSeries.total_bounds so, it should be a easy as

buildings.total_bounds

which returns an array like ([ 0., -1., 3., 2.])

Upvotes: 1

Related Questions