Calculating fields - add start and end coordinates of line features to table

3071
10
Jump to solution
04-16-2013 01:41 AM
AlexanderPichlmayr
New Contributor
Hello everybody,

Since a wile I am serching a way to solve a problem but cant get to any result.
What I want to do is to add koordinates of the startpoint and endpoint of a line-feature to its attribute table.
In my project I have to traw a great number of lines (representing power grid) so I manually added 4 fields (StartX, StartY, EndX, EndY). Is there any toold in arc toolbox that can help me calculate the koordinates for those 4 fields. Manually adding the data would be very time consuming. For better understanding i attached a photo with a sample of the grid (green line) and its attribute table.


Thanks for any kind of help
Alex
0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Esteemed Contributor
Right click on one of the field headings and select calculate geometry.  You'll be presented with a a pull down to select what you want to calculate.
That should just about do it....

View solution in original post

0 Kudos
10 Replies
JoeBorgione
MVP Esteemed Contributor
Right click on one of the field headings and select calculate geometry.  You'll be presented with a a pull down to select what you want to calculate.
That should just about do it....
0 Kudos
AlexanderPichlmayr
New Contributor
Very good thanks a lot. That helps calculating the start and endpoint of a line-feature. Is there also a way to generate coordinates of vertex points?
0 Kudos
JoeBorgione
MVP Esteemed Contributor
Very good thanks a lot. That helps calculating the start and endpoint of a line-feature. Is there also a way to generate coordinates of vertex points?


Found this with a google search (with apologies to bing users...)
That should just about do it....
0 Kudos
AlexanderPichlmayr
New Contributor
Hey thanks for the link. I tryed it already but it seems the tool does not work on arggis 10. (tool is from 2006). When I use it it shows up with the error " no module named win32api found failed to execute". I have Python 2.6(.5) installed and tryed with downloeading the extentions already -> no improvement! Dont really know what elese I can try!?
0 Kudos
RobertPotter
New Contributor II
Hi,

I have a similar problem but I need to put the calculation of the coordinates (start and end of a line) into a model or script so it can be run on a regular basis.

Any clues?
0 Kudos
RichardFairhurst
MVP Honored Contributor
Hi,

I have a similar problem but I need to put the calculation of the coordinates (start and end of a line) into a model or script so it can be run on a regular basis.

Any clues?


It has to be done as a Python9_3 Field Calculation (at least at 10.0 and up) connected to a layer created with the Make Layer tool (not a feature class stored on disk, which is the normal output of most tools).  It is a simple calculation:

!Shape.FirstPoint.X! - does the Start/From end X coordinate
!Shape.FirstPoint.Y! - does the Start/From end Y coordinate
!Shape.LastPoint.X! - does the End/To end X coordinate
!Shape.LastPoint.Y! - does the End/To end Y coordinate

M and Z can be substituted for X or Y above, and Centroid can be used instead of FirstPoint/LastPoint to get the midpoint of the line.  http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000004m000000
0 Kudos
RobertPotter
New Contributor II
Thanks but it didn't work, well it did for a while then I got this after nearly 3 minutes

Start_X !Shape.FirstPoint.X! PYTHON_9.3 #
Start Time: Thu May 16 12:00:07 2013
ERROR 000539: Error running expression: GPVARIANTOBJECT0.FirstPoint.X
Traceback (most recent call last):
  File "<expression>", line 1, in <module>
SystemError: error return without exception set

The index was either too large or too small.
Failed to execute (Calculate Field).
Failed at Thu May 16 12:02:50 2013 (Elapsed Time: 2 minutes 43

What does it mean?  Essentially what you told me was correct and it worked a bit then stopped!!

It did 1970 of the 2843 in the file

[ATTACH=CONFIG]24353[/ATTACH]
0 Kudos
RobertPotter
New Contributor II
Ah overall thank you!

The problem above I have found out is on the client end (ie. my machine) basically it just ran out of memory.  I have now freed some memory and it works fine.

Thanks
0 Kudos
RobertPotter
New Contributor II
Oh well as would be the case I spoke too soon.  Initially, it did finish but when I actually reviewed the results It had only calculated the coordinates for the first 1970 records (Start_X, Start_Y, End_X, End_Y) ???? 
So to check that result I tried to redo it but this time ArcMap CRASHED!!!  It asked if I wanted to send an error report to ESRI and I said yes, why not?

Then comes the funny bit....

...then would you believe it that Crashed also!!!
[ATTACH=CONFIG]24354[/ATTACH]

So really it is back to my original question ... how do I do this?????
0 Kudos