I'm new to python and arcpy but I've been trying to learn how to run geoprocessing tools using arcpy. I have (for this example) 2 shapefiles, a and b, which are both polygons. From plotting them in arcMap, I know that b is found entirely within a.
I would like to write a script that will take these two shapefiles and give me a True/False response about whether or not one polygon contains the other. I was thinking of using the arcpy.Geometry.contains() function.
I have the following:
>>> a_shp="C:\\Data\\shapefile_a.shp"
>>> b_shp="C:\\Data\\shapefile_b.shp"
>>> #read in as geometry
>>> a=arcpy.CopyFeatures_management(a_shp, arcpy.Geometry())
>>> b=arcpy.CopyFeatures_management(b_shp, arcpy.Geometry())
>>> arcpy.Geometry.contains(a[0],b[0])
False
>>> arcpy.Geometry.contains(b[0],a[0]) #maybe I got the order wrong? Trying the other order
False
>>> #Maybe I'm getting the syntax wrong, trying something else
>>> a[0].contains(b[0])
False
>>> b[0].contains(a[0])
False
I get no error messages but clearly something isn't working properly. Am I doing this right?