首页 > 解决方案 > 地理数据框中所有线串(约 100 万)的凸壳

问题描述

我有一个带有 ca 的 Geopandas 数据框。100 万个线串,我想用 Geopandas 的相应工具 (GeoSeries.convex_hull) 计算它们的凸包。这会导致计算时间很长(大约 4 小时)。有人知道如何更快地做到这一点吗?

地理数据框如下所示:

   s_p_ed_hik  length lanes  i                                         geometry
0    2.658196   4.263  None  0  LINESTRING (8.52441 47.39506, 8.52443 47.39502)
1    2.658196   4.263  None  0  LINESTRING (8.52441 47.39506, 8.52443 47.39502)
2    2.874100   4.343  None  0  LINESTRING (8.52443 47.39502, 8.52449 47.39502)
...

以下是有关我的 Geopandas Dataframe 的 Linestrings 长度的统计信息:

count    1063284.000000
mean         12.693328
std          13.335160
min           0.385000
25%           4.956000
50%           9.507000
75%          13.638000
max         287.713000

标签: pythongeopandas

解决方案


确保您已pygeos安装 - https://geopandas.readthedocs.io/en/latest/getting_started/install.html#using-the-optional-pygeos-dependency。这将为您提供矢量化操作和大幅加速。

conda install -c conda-forge pygeos

你也可以尝试dask-geopandas做多核。

pip install git+https://github.com/geopandas/dask-geopandas.git

https://github.com/geopandas/dask-geopandas


推荐阅读