from osgeo import ogr dSource = ogr.Open( "parcel_address.shp" ) if dSource is None: print "[ ERROR ]: datasource cannot be opened" layer = dSource.GetLayer() geom_collection = [] # # collect just the geometries # notice that we are losing reference # each geometry's parent feat though # for feat in layer: geom = feat.GetGeometryRef() geom_collection.append( geom ) # # try to print the # geometries collected # for g in geom_collection: print g.ExportToWkt() <..PYTHON CRASHES..>
官方的陷阱对为什么Python崩溃时删除,还有几何参考使用具有良好的部分。他们甚至谈论如何转化为基本的C++参考。更微妙的情况下发生时,你松散的引用的功能,而不删除它的例子如下所示。
Copyright © Since 2014.
开源地理空间基金会中文分会
吉ICP备05002032号
Powered by TorCMS