Currently I am making a script that allows the user to draw a line, the line is then created into end points with lat/long available.

From this lat/long, I have to run some math equations to figure out where the next coordinates should be. I have gotten it to create the points based on a line, calculate the bearing, and used ArcPy to place the next point into the shapefile using my math equation as a test.

I am using Arcmap 10.4 for testing. I have access to Pro and 10.7, but I am using 10.4 just to learn.

My question is how do I read the attributes of a file so that I can use the X/Y of a point to run my equations on?

I have (light) experience using Pandas, working with CSV's etc just very new to ArcPy. Below is a list of what I am doing to make it easy.

  1. Create line. Use COGO to add bearing.
  2. Create points from lines.
  3. Read attribute table. Read X/Y. (This is what I need help with).
  4. Run equation on X/Y to get the next 4 points.
  5. Add points to point shapefile.

When I have it figured out I can provide an update to share the code with for future use.

  • You could just use the make XY event layer tool which makes an in-memory layer object which you can either process directly or save out to a permanent dataset which you process (e.g. add new fields to).
    – Hornbydd
    Commented Mar 24, 2021 at 19:07
  • I will take a look at using this option. That sounds like it would be useful for this. Commented Mar 24, 2021 at 20:09

1 Answer 1


Try the da.SearchCursor:

SearchCursor establishes read-only access to the records returned from a feature class or table.

With the SHAPE@XY token:

import arcpy

fc = r'C:\path\to\data.gdb\featureclass'

with arcpy.da.SearchCursor(fc, 'SHAPE@XY') as cursor:
    for row in cursor:
        x, y = row[0]

enter image description here

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.