[FWTools] GEOS contains fails after multiple iterations on windows
bryan at geomega.com
Mon Mar 13 18:01:21 EST 2006
I posted this problem a couple weeks ago and haven't heard any answers.
Today I was able to test the same Python code on a linux machine, and it
worked fine. Frank, I know GEOS is relatively new in the FWTools
release. Are others able to successfully use Python and GEOS via
FWTools on windows? Thanks for any insights.
Bryan Keith wrote:
> 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 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
>> #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"
>> 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 Keith
>> GIS Specialist
>> Geomega, Inc.
>> Boulder, CO, USA
>> FWTools mailing list
>> FWTools at lists.maptools.org
More information about the FWTools