python - 地理数据框中所有线串(约 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
解决方案
确保您已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
推荐阅读
- javascript - Javascript拼接与redux一起工作错误
- reactjs - 反应问题。始终检查星级输入
- c++ - 如何将带有特殊字符的 QString 转换为字节流以通过 Linux 管道发送
- mariadb - 多个用户同时访问同一个 Mariadb 数据库
- php - 我网站上的 PHP 计数器坏了
- javascript - 在桌面使用 chrome 移动视图和在移动设备中使用 chrome 的区别
- pine-script - 尝试编写代码,在进行下一次交易之前为策略提供缓冲时间,声明问题
- php - 在 json 数组中搜索函数 SQL
- assembly - 在 x86 程序集中的代码段内定义数据
- r - 如何在保留唯一列的同时重新绑定数据集?