简体   繁体   中英

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})
...

城市 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

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.])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM