osmnx 将任何其他空间几何、放置边界、建筑物覆盖区或兴趣点下载为 GeoDataFrame
时间: 2024-05-02 20:18:55 浏览: 10
OSMnx 可以下载任何其他空间几何、放置边界、建筑物覆盖区或兴趣点,并将其转换为 GeoDataFrame。以下是一个示例:
```python
import osmnx as ox
# 下载一个城市的边界
city = ox.gdf_from_place('Los Angeles, California, USA')
# 下载一个城市的建筑物覆盖区
buildings = ox.buildings_from_place('Los Angeles, California, USA')
# 下载一个城市的兴趣点
parks = ox.pois_from_place('Los Angeles, California, USA', amenities=['park'])
# 下载一个城市的道路网络
graph = ox.graph_from_place('Los Angeles, California, USA')
# 将这些数据保存为 shapefile 文件
ox.save_gdf_shapefile(city, filename='la_boundary')
ox.save_gdf_shapefile(buildings, filename='la_buildings')
ox.save_gdf_shapefile(parks, filename='la_parks')
ox.save_graph_shapefile(graph, filename='la_roads')
```
在这个示例中,我们首先使用 `gdf_from_place()` 函数下载了洛杉矶的边界,并将其保存为一个 GeoDataFrame 对象。然后,我们使用 `buildings_from_place()` 函数下载了洛杉矶的建筑物覆盖区,并将其保存为另一个 GeoDataFrame 对象。接下来,我们使用 `pois_from_place()` 函数下载了洛杉矶的公园兴趣点,并将其保存为另一个 GeoDataFrame 对象。最后,我们使用 `graph_from_place()` 函数下载了洛杉矶的道路网络,并将其保存为一个 shapefile 文件。注意,我们使用 `save_gdf_shapefile()` 和 `save_graph_shapefile()` 函数将这些数据保存为 shapefile 文件。