I'm trying to get the First Point coordinates (x,y) and Final Point coordinates (x2,y2) from a polyline in ArcGIS 10 with the Field calculator.

I've added 4 (double) fields like StartX,StartY,EndX and EndY,I tried with:


But no luck. The error: "The row contains a bad value".

What am I doing wrong?

Thanks to @radouxju for your answer because it was what I was looking for!!, but NOW I don't know What's happening with my ArcGIS10. Let's see:

I could compute all these statements (4), to every field:

  • "!Shape!.lastPoint.X"
  • "!Shape!.lastPoint.Y"...

But, after that I checked for errors and I found this! That there are times that the ArcGIS field calculator doesn't compute well. In the example, the yellow one, it's 16 meter long, but its coordinates are the same, but the the next polyline is well computed... What's happening?

Error with ArcGIS10


1 Answer 1


you do not need "positionalongline" in your case. A simple snippets would be:


similarly, you can use


However, this should have worked. So the first thing to do is to use Repair Geometry to remove problematic rows, or use a code block to handle issues in your features

def robustFX(shp):
    if (shp and (shp.length > 0)):
        return str(shp.FirstPoint.X)
        return "no data"
  • Thanks @radouxju !!it works with: "!Shape!.firstPoint.X" in a String field. ;)
    – juasmilla
    Commented Jun 4, 2014 at 10:36
  • QUESTION edited, found some troubles :( @radouxju
    – juasmilla
    Commented Jun 5, 2014 at 12:01
  • maybe it is a naive question, but how long is your line when you measure it on the screen ?
    – radouxju
    Commented Jun 5, 2014 at 12:13
  • I measured myself again and the same as shown in "Shape_Lenght"
    – juasmilla
    Commented Jun 5, 2014 at 13:32
  • this is really strange, could you please try with "!Shape!.positionAlongLine(0.5,True).firstPoint.Y". Could you also start an edit session and check the from and to coordiantes of this strange line.
    – radouxju
    Commented Jun 5, 2014 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.