Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having trouble getting the start and end point of a line using the code below.

import arcpy

with arcpy.da.SearchCursor("Lines",["Material","SHAPE@"]) as curs:
    for row in curs:
        startptx = row[1].firstPoint.X
        startpty = row[1].firstPoint.Y

The error I get is as followed: AttributeError: 'NoneType' object has no attribute 'firstPoint'

I am using ArcMap 10.3.1

share|improve this question
4  
Are you testing for nil and NULL shapes? – Vince Feb 6 at 14:27
    
That was it. I just checked and I have 20 null. Thank you! – JotDot Feb 6 at 14:42

The problem was that I had null values. Make sure to check your data for null/nil values!

if row[1]:
    startptx = row[1].firstPoint.X
else:
    print "There are null values in your data"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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