# Measuring distance to two Points in ArcPy?

I would like to know how to measure the distance from two Points in ArcPy?

I know only Geometry has the distanceTo method but how do I could make a typecast in ArcPy?

I got the following error message:

``````Runtime error
Traceback (most recent call last):
File "<string>", line 10, in <module>
AttributeError: 'Point' object has no attribute 'distanceTo'
``````

Here is my code:

``````'''

... ptIni = {}
... ptEnd = {}
... for row in arcpy.SearchCursor("polilinha"):
...     ptIni = row.Shape.firstPoint
...     ptEnd = row.Shape.lastPoint
... print ptIni.distanceTo(ptFim)
``````
• You have a polyline and what to know the distance from first to last Point measured as a straight line (not along the line)? – BERA Feb 1 at 12:27
• The last version of ArcGIS that didn't support Data Access cursors is now long retired, so it's time to start actively discouraging the use of the less-than-Pythonic `arcpy.SearchCursor`. Instead, use `arcpy.da.SearchCursor`, which is both faster and easier to integrate into Python list operators. If you read the doc on `firstPoint/lastPoint`, you'll see the result type is `Point`, but that `distanceTo` is an operation of `PointGeometry`. Be careful to retrieve the `SpatialReference` of the source layer and apply it to the `PointGeometry` constructor or the precision could be lost. – Vince Feb 1 at 12:35
• Point doesn't have distanceTo. pointGeometry does. – nickves Feb 1 at 12:38
• @BERA actually I need to find the walfway point by measuring distances between polyline parts (path). – Ezequias Feb 1 at 12:56
• You've changed this question in comments enough to break the answer, and now the answer doesn't address the question. Please Edit the Question to ask the question you want answered. If you have a new question, you can ask it as a separate Question. – Vince Feb 1 at 13:56

To find mid point use positionAlongLine with `use_percentage=True`:
``````import arcpy