【发布时间】:2016-03-29 10:55:25
【问题描述】:
我们正在使用shapely 库来检查某个随机点是否不在形状文件中存储的某些禁止区域内。
with fiona.open(path) as source:
geometry = get_exclusive_item(source[0])
geom = shapely.geometry.shape(geometry['geometry'])
def check(lat, lng):
point = shapely.geometry.Point(lng, lat)
return not geom.contains(point)
但是最近一次调用geom.contains(point) 大约需要一秒钟才能完成。是否有其他更快的 python 库,或者我们可以以某种方式优化形状文件以获得更好的速度?
【问题讨论】:
-
你的 shapefile 有空间索引吗?
-
您安装了 GEOS 吗?并确保 Shapely 能找到它?
标签: python geospatial shapefile