AnsweredAssumed Answered

populate x,y

Question asked by 2Quik1 on Jul 29, 2015
Latest reply on Aug 13, 2015 by bixb0012

I am trying to populate ever point's x,y when a point is created by a mouse click or clicking. Some times i might only create one point but sometimes i may have to create more then one. I am having trouble populating the x,y of the new created points.

 

this is currently what i have. I know it's wrong. i would like to see how to do this correctly.

 

getting error at

Traceback (most recent call last):

  File "C:\GIS\Python\AddPoint\AddPoint_4.py", line 18, in <module>

    geom = prow.SHAP

AttributeError: 'tuple' object has no attribute 'SHAPE'

 

Failed to execute (Script).

 

#import modules  
import arcpy  

arcpy.env.qualifiedFieldNames = False
pointFC = "Animal Sightings" #target point feature class Animal Sightings

mxd = arcpy.mapping.MapDocument("CURRENT")  
df = arcpy.mapping.ListDataFrames(mxd)[0]  
dfsr = df.spatialReference  
fcsr = arcpy.Describe(pointFC).spatialReference  
if dfsr.name == fcsr.name:  
    """Now do your work"""  

point = arcpy.GetParameterAsText(0)  #click

for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):        
        x,y = prow[0]
        geom = prow.SHAPE
        prow.x = geom.X
        prow.y = geom.Y
del prow          

insCursor = arcpy.da.InsertCursor(pointFC,('POINT_X','POINT_Y','SHAPE@XY')) # create insert cursor  

with arcpy.da.SearchCursor(point,('POINT_X','POINT_Y','SHAPE@XY')) as cursor: # loop through feature set  
    for row in cursor:
        POINT_X = row[0]    
        POINT_Y = row[1]
        insCursor.insertRow(row) # insert row  

del insCursor # delete insert cursor          

Outcomes