更新:通过进一步的调查,我发现它必定是由某种程度上损坏的几何造成的。但即使我跑:
if drillhole[1].IsValid():
导致崩溃。所以不确定如何检查它。
我正在尝试测试线条是否在多边形内。使用匀称它除了速度之外对我很有用 - 我有十万行和多边形相同。我只想测试ogr是否可以更快地完成这项任务,但没有运气使其成功。
import ogr
#Load cells as polygons with slight buffer
data_source = ogr.Open(file_path_cells)
source_layer = data_source.GetLayer()
source_layer.ResetReading()
cells = []
for source_feature in source_layer:
feature_id = source_feature.GetFieldAsInteger(0)
feature_geometry = source_feature.geometry()
feature_geometry = feature_geometry.Buffer(0.1, quadsecs = 3)
cells.append((feature_id,feature_geometry))
#Load drillholes as lines wihtin cells
data_source = ogr.Open(file_path_drillholes)
source_layer = data_source.GetLayer()
source_layer.ResetReading()
drillholes = []
for source_feature in source_layer:
feature_elev = source_feature.GetFieldAsInteger("elev")
feature_geometry = source_feature.geometry()
drillholes.append((feature_elev,feature_geometry))
for cell in cells:
for drillhole in drillholes:
if cell[1].Contains(drillhole[1]):
print("yes")
else:
print("no")
知道线路有什么问题吗?:
if cell[1].Contains(drillhole[1]):
在我的Windows 7机器上,我总是让python.exe停止工作...... 问题签名:
Problem Event Name: APPCRASH
Application Name: python.exe
Application Version: 0.0.0.0
Application Timestamp: 5193f3af
Fault Module Name: gdal111.dll
Fault Module Version: 1.11.2.0
Fault Module Timestamp: 54e65215
Exception Code: c0000005
Exception Offset: 00000000005e5fb3
OS Version: 6.1.7601.2.1.0.768.3
或者还有其他一些更快捷的方式或方式如何使用匀称来提高速度?