I am trying to use 2 geometry objects to check if a line is within a (rather complex) polygon. The geometry check always fails, even if the line is clearly within the polygon. I use the following code:
#get the polygon sC = arcpy.SearchCursor(polygon) for row in sC: polygonshape = row.Shape del sC #creation of the polyline(s): feature_info = [[[p1.x, p1.y], [x, y]], [[p2.x, p2.y], [x, y]], [[p3.x, p3.y], [x, y]]] features =  for feature in feature_info: array = arcpy.Array() for point in feature: P = arcpy.Point() P.X = point P.Y = point array.add(P) features.append(arcpy.Polyline(array)) #the actual check: for item in features: in_poly = polygonshape.contains(item) #this is always false
Any ideas why this fails? I considered, that one of the layers (polygon) has a coordinate system, while the other doesn't but according to another answer here (which I can't find right now) coordinate systems are supposedly ignored for this kind of checks. Could the size/complexity of the Polygon be an issue?
If I create a Feature Class of the line and do a spatial selection (within) afterwards, it works as expected. Also: this behaviour returns unexpected results for contains as well as within.