在、包含或其他中使用ogr时,Python gdal停止工作
更新:通过进一步调查,我发现这一定是由几何体损坏引起的。但即使我跑步:在、包含或其他中使用ogr时,Python gdal停止工作,python,windows,gdal,shapely,ogr,Python,Windows,Gdal,Shapely,Ogr,更新:通过进一步调查,我发现这一定是由几何体损坏引起的。但即使我跑步: if drillhole[1].IsValid(): 是它造成了这次事故。所以不知道如何检查它 我试图测试直线是否在多边形内。使用shapely,除了速度之外,它对我非常有效——我有上万条线,多边形也是如此。我只是想测试一下ogr是否可以更快地完成这项工作,但没有运气让它工作 import ogr #Load cells as polygons with slight buffer data_source = ogr.Op
if drillhole[1].IsValid():
是它造成了这次事故。所以不知道如何检查它
我试图测试直线是否在多边形内。使用shapely,除了速度之外,它对我非常有效——我有上万条线,多边形也是如此。我只是想测试一下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]):
在我的两台Windows7机器上,我总是发现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
或者有没有其他更快的方法,或者如何使用shapely来提高速度?这次崩溃很可能是一次有充分记录的事故
类似的工作也可以用Shapely来完成,但Shapely没有这种能力。此外,使用索引可以更快地完成for循环中的查询,还有一些与shapely+Rtree相关的问答。谢谢,正如我在问题中所写,我首先使用了shapely。我使用shapely_geometry=load(source_feature.geometry().ExportToWkt())和shapely“contains”都很好。但是想试试ogr是否能更快地完成这个操作。我想不管怎样,Rtree是一个不错的选择,再次感谢。