Back in Avenue days, I was able to use something like
if ((checkPoly.Contains(testline).Not)) then ...
To test wither my line segment (testline) was contained within the study polygon (checkpoly). I'm now trying to do the sam type of test use the .within method.
I have created my line geometry and polygon geometry, but I'm receiving Runtime error. I have also tried it with a pt geometry. All three geometries are in the same spatial reference and should return a "true" in both cases. As powerful as geometries are and as often as I use them, I never seem to be able to get the "light bulb" to go off in my head....so any suggestions are welcome. I have looked at other threads including https://community.esri.com/thread/69044#comment-400410 and may pursue that, but my guess is it is something simple I am missing.
>>> polyGeom = arcpy.CopyFeatures_management(inStudy, arcpy.Geometry())
... ptGeom = arcpy.PointGeometry(arcpy.Point(ptX, ptY, 0, 0, ptid))
... tmpTrans = geo.segmentAlongLine(startDist, endDist)
...
... print("check for pt within poly")
... ptGeom.within(polyGeom)
... print("check for line within poly")
... tmpTrans.within(polyGeom)
...
check for pt within poly
Runtime error
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\arcobjects\arcobjects.py", line 771, in within
return convertArcObjectToPythonObject(self._arc_object.Within(*gp_fixargs([second_geometry])))
ValueError: [<geoprocessing describe geometry object object at 0x1E43D4E0>]
>>> print("check for line within poly")
... tmpTrans.within(polyGeom)
...
check for line within poly
Runtime error
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\arcobjects\arcobjects.py", line 771, in within
return convertArcObjectToPythonObject(self._arc_object.Within(*gp_fixargs([second_geometry])))
ValueError: [<geoprocessing describe geometry object object at 0x1E43D4E0>]
>>>
Sorry about the formatting.....I was trying to include the errors. Thanks.
tagging python snippets in case anyone has any snippets already to do this.