[FWTools] GEOS contains fails after multiple iterations
Bryan Keith
bryan at geomega.com
Wed Feb 22 12:27:24 EST 2006
Something I didn't mention: grid_py is a polygon shapefile so I use
Centroid to get the point for the contains method. If I use a point
shapefile and just use myPTC = myFeature.GetGeometryRef(), then the
script runs without a problem.
Bryan
Bryan Keith wrote:
> I'm having a problem with GEOS using Python and FWTools1.0.09a on
> Windows 2000. I've simplified my code to the point where I can
> reproduce the error in this short script:
>
> import ogr
> #get valley file polygon
> myVFPY = ogr.CreateGeometryFromWkt("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")
> #get grid shapefile
> ogrSDS = ogr.Open("S:\\ProductionData\\Data\\GWModel", 1)
> ogrSLayer = ogrSDS.GetLayerByName("grid_py")
> #for i in range(ogrSLayer.GetFeatureCount()):
> #for i in range(10, 100):
> for i in range(100, 200):
> print str(i)
> myFeature = ogrSLayer.GetFeature(i)
> myGeom = myFeature.GetGeometryRef()
> myPTC = myGeom.Centroid()
> #the following line fails at the 33rd time in the loop
> if myVFPY.Contains(myPTC):
> print "Contains myPTC"
> else:
> print "Does not contain myPTC"
>
>
> I get a "memory could not be read" error from the Contains() method
> during the 33rd iteration of the loop. The failure is not dependent
> on the point as I've tested various sets of features in ogrSLayer.
> The failure always happen the 33rd time through the loop. Nor is the
> failure dependent on the shapefile or the polygon. I've tested
> multiple of each.
>
> Anyone know what I'm doing wrong here?
>
> Bryan
>
> Bryan Keith
> GIS Specialist
> Geomega, Inc.
> Boulder, CO, USA
> _______________________________________________
> FWTools mailing list
> FWTools at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/fwtools
> http://fwtools.maptools.org/
>
>
More information about the FWTools
mailing list