#get the first point feature and the first line feature poi = arcpy.da.SearchCursor("POIs","SHAPE@").next()[0] line = arcpy.da.SearchCursor("Streets","SHAPE@").next()[0] print poi.distanceTo(line) #returns 0.017893575694200557 #get first part of line part = line.getPart(0) #get the first two points on that part p0 = part[0] p1 = part[1] #make a new polyline out of those two points seg = arcpy.Polyline(arcpy.Array([p0,p1])) print seg.length #returns 0.0017140186696764268, so the segment is there as a polyline #try to get the distance from the poi to the segment poi.distanceTo(seg)
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 809, in distanceTo return convertArcObjectToPythonObject(self._arc_object.DistanceTo(*gp_fixargs((other,)))) ValueError: <geoprocessing describe geometry object object at 0x16068EE0>
Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 779, in distanceTo return convertArcObjectToPythonObject(self._arc_object.DistanceTo(*gp_fixargs((other,)))) ValueError: <geoprocessing describe geometry object object at 0x0D04CCC0>
polylineGeometry.distanceTo(justPoint) will work
pointGeometry.distanceTo(polylineGeometry) will not.