Correct syntax for using arcpy.Geometry.touches or .intersects methods

8479
11
08-03-2010 06:57 AM
StevenLambert
New Contributor
Am trying to test new polygon created in script for overlap against an existing polygon feature class that may contain one or more multippart polygons.  Can seem to get the right syntax.  Keep getting failure on second geometry parameter.....

# First create geometry object to receive existing polygon features

inML = arcpy.geometry()

# Copy in features from fc to geometry object

arcpy.CopyFeatures_management(infc, inML)

# Have polygon footprint in an array, aFoot, create geometry object

test_poly = arcpy.Geometry("polygon", aFoot)

# test for overlap

intersect = inML.touches(test_poly)

or

intersect = inML.intersects(test_poly)

Both fail with a second geometry error....

Any ideas?

Thanks.
0 Kudos
11 Replies
AustinMulder
New Contributor II
I am also trying to do something similar: have a user specify either a point or a polygon and return True or False depending on weather or not it is within a study area polygon.

To test i digitized a simple single part single feature polygon, as well as a single point directly in the center of the polygon.

Unfortunately this returns false - when i know for certain the point is within the polygon.


pointShp = "c:/temp/temp.shp"
polyShp = "c:/temp/temppoly.shp"

gL = arcpy.CopyFeatures_management(pointShp, arcpy.Geometry())

array = arcpy.Array()
rows = gp.SearchCursor(polyShp)
row = rows.Next()
while row:
    feat = row.shape
    pnt = feat.getPart()
    array.add(pnt)
    row = rows.Next()
array.add(array[0])

Poly = arcpy.Polygon(array)

intersect = gL[0].touches(Poly)

print intersect


Any ideas?
thanks,
0 Kudos
JasonScheirer
Occasional Contributor III
Are you sure you're looking for touches and not within or contains or not disjoint? Touches only returns true if the geometry lies on the edge of the other geometry.
0 Kudos