Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have an arcpy script that makes calculations based on an input PolygonZ feature class. What I need to do in several places in the script is test whether a point falls within a polygon in 2D. In these cases I have a 3D geometry object for an input polygon and a 2D geometry object for a test point that I create on the fly. I use the pntgeom.within(polygeom) comparison. The problem is that this statement always evaluates to False. So, I am wondering if the comparison is actually working in 3D (and implicitly giving the point a Z value of 0), in which case the point will not ever be "within" the polygon. The polygons are 3D surfaces raised above the ground. The whole procedure is intended to determine which of two possible sizes the current surface possesses. I create a test point that would fall only within the larger size, and, if the point is not within (2D) the current surface polygon, then the size must be the smaller one. Specifically my code chooses between two different arc radius lengths. Here is the relevant code snippet:

pntTest = arcpy.Point()
pntTest.X = coords_A[0] + (12200.0 * uCLA[0])
pntTest.Y = coords_A[1] + (12200.0 * uCLA[1])
pntGeom = arcpy.PointGeometry(pntTest)
testpnt = pntGeom.centroid
arcpy.AddMessage('  Test point coords:  X = %s   Y = %s' % (str(testpnt.X), str(testpnt.Y)))
where = '"OISSURTY" = \'%s\' AND "RWYDESG" = \'%s\'' % (surfInfo[0], surfInfo[2])
arcpy.MakeFeatureLayer_management(oids, 'oidsurfs', where)
cnt = arcpy.GetCount_management('oidsurfs').getOutput(0)
arcpy.AddMessage('  No. featurs in layer "oidsurfs" = %s' % str(cnt))
surf_sc = arcpy.SearchCursor('oidsurfs', "", spatref)
shapefieldname = desc_oids.shapeFieldName
for row in surf_sc:  #should be only 1
    surfGeom = row.getValue(shapefieldname)
del row
del surf_sc
len = surfGeom.length
arcpy.AddMessage('  surfGeom length = %s' % str(len))
if pntGeom.within(surfGeom):
    radius = 10000.0
    radius = 5000.0
arcpy.AddMessage("  Distance of opnt from rwy end = %s" % str(dist))
arcpy.AddMessage("   Inner arc radius (conical surface) = %s" % str(radius))

I have checked the coordinates of the test point and confirmed that it lies within (2D) the current polygon. This also confirms that it is a geometry object. I also call the length property on the polygon geometry to confirm whether it too is a geometry object; it is. The current data I am testing has all polygons being of the larger size, so the code should choose the larger radius (which is used in a later calculation). The problem is that the geometry object comparison evaluates to False: no errors - just doesn't work. I thought these were 2D comparisons, but now I'm beginning to wonder. I just don't get it. Any ideas?

ArcGIS-ArcView 10.0 Windows 7 8 GB RAM

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.