组合OSMnx多面体

时间:2018-09-14 16:13:48

标签: python gis geopandas osmnx

使用OSMnxgdf_from_places()生成以组为单位获取的多面体联合的最佳实践是什么?

gboeing02-example-osm-to-shapefile.ipynb示例中,使用gdf_from_places()方法将多个shapefile从OSM下载到地理数据框。几何图形作为多面体存储在Geopanda的数据框中,每行代表一个位置。

# you can pass multiple queries with mixed types (dicts and strings)
mx_gt_tx = ox.gdf_from_places(queries=[{'country':'Mexico'}, 'Guatemala', {'state':'Texas'}])
mx_gt_tx = ox.project_gdf(mx_gt_tx)
fig, ax = ox.plot_shape(mx_gt_tx)

osmnx gdf_from_places example

关于这个问题,我已经尝试过使用Geopanda的GeoSeries.unary_union,但想知道其他人是如何在Python中以编程方式完成此工作的。

当前流程2018

此方法使用Shapely function of unary_union(否则将是@joris注释指出的通过Geopandas的mx_gt_tx [“ geometry”]。unary_union。

queries = [{'country':'Mexico'}, 'Guatemala', {'state':'Texas'}]

# buffer_dist is in meters
mx_gt_tx = ox.gdf_from_places(queries, gdf_name='region_mx_gt_tx')
mx_gt_tx

Imgur

# project the geometry to the appropriate UTM zone then plot it
mx_gt_tx = ox.project_gdf(mx_gt_tx)
fig, ax = ox.plot_shape(mx_gt_tx)

Imgur

# unary union through Geopandas
region_mx_gt_tx = gpd.GeoSeries(unary_union(mx_gt_tx["geometry"]))
region_mx_gt_tx.plot(color = 'blue')
plt.show()
print(region_mx_gt_tx )

Imgur

1 个答案:

答案 0 :(得分:1)

import osmnx as ox
gdf = ox.gdf_from_places(queries=[{'country':'Mexico'}, 'Guatemala', {'state':'Texas'}])
unified = gdf.unary_union