Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

problems with distanceTo from a point geometry to a new polyline

$
0
0
I'm trying to call distanceTo from a PointGeometry to a Polyine and am running into trouble whenever the polyline is one I just cooked up. Any pointer on what I'm doing incorrectly would be welcome.

Code:

#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)

This is what comes back:

Code:

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>


Viewing all articles
Browse latest Browse all 2485

Trending Articles