Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Here is my code

#arcpy
import arcpy,sys

from arcpy import env

env=r"C:\Users\Jaya\Desktop\python_practice"
totalRec=arcpy.GetCount_management("river")

rows=arcpy.SearchCursor("river")
row=rows.next()

pp=[]

for row in rows:
    initialH=row.RASTERVALU
    for r in range(1,55):
        val=val+1
        headav=initialH-row.RASTERVALU
        if(headav>=50):
            if(r>=12):
                break
        elif(headav<50):
            if(r>=12):
                row=rows.next()

        row=rows.next()
    print headav
    pp.append((row.POINT_X,row.POINT_Y_1,headav))
    row=rows.next()


pt=arcpy.Point()
ptGeoms=[]

for p in pp:
    pt.X=p[0]
    pt.Y=p[1]
    pt.Z=p[2]
    ptGeoms.append(arcpy.PointGeometry(pt))

arcpy.CopyFeatures_management(ptGeoms,r"C:\Users\Jaya\Desktop\python_practice\power_plant.shp")

I am getting error message like this: Runtime error : 'NoneType' object has no attribute 'RASTERVALU'

Can you help me in this regards

share|improve this question
2  
Your question is very vague. Can you tell us more what you are trying to do, and maybe what line in your code is erroring? –  artwork21 Apr 28 '13 at 17:10
2  
"RASTERVALU" looks like a typo for "RASTERVALUE" or something like that. –  whuber Apr 28 '13 at 17:56
    
What is the data type of layer "river"? If it does not have attributes then that could explain the error. –  PolyGeo Apr 28 '13 at 21:58
    
River is a shape file –  Jaya Pudashine Apr 29 '13 at 9:58
    
I have river network shape file in river layer. I need to check for the criteria of head difference between the starting point and consecutive point. Minimum head difference should be 50m and Minimum distance between two points should be 1080. In my case distance between two consecutive points is 90m. So i have given minimum count as 12 –  Jaya Pudashine Apr 29 '13 at 10:01
show 2 more comments

2 Answers 2

As you are using a for loop to iterate through the rows there is no need to use row=rows.next() see online help for an example. Inside the if statement you can simply use continue to ignore the rest of the for loop and move to the next row.

The break statement, breaks out of the smallest enclosing for or while loop.

The continue statement, continues with the next iteration of the loop.

share|improve this answer
    
I have tried removing row=rows.next(), it is not working it it giving the same result as input file –  Jaya Pudashine Apr 29 '13 at 10:02
2  
Did you remove all 4 cases where you were using it. The error message you get suggests that in the line headav=initialH-row.RASTERVALU you attempt to access the RASTERVALU property on the row variable but row is equal to None which is equivalent to null in Python. This may mean you have moved row beyond the end of the cursor. –  Neil Etheridge Apr 29 '13 at 23:27
add comment

If the "river" feature class is a shapefile, you need the ".shp" added when you reference it. Try changing the following line:

rows=arcpy.SearchCursor("river.shp")
share|improve this answer
add comment

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.