AnsweredAssumed Answered

Update points attributes based on there location.

Question asked by 2Quik1 on Jul 30, 2015
Latest reply on Aug 11, 2015 by 2Quik1

I currently have a script that allows me to use a mouse click and create points on a map of where there are animal sightings and works great.

But i would like to update the attributes of the points that i create when using the script. I have found a similar script but the script i found only updates the points attributes one at a time. The script that i am working on would allow me to click on a map at different locations in one session and update the points attributes, but the points may not be on the same parcel.


With the help of Darren Wiends and the use Wes MIller scipt i have put together the following but i don't know how to change it to update more then one point at a time. help please.


Re: populate x, y on mouse click



I get the following error with my modified version of Wes Miller code.


Traceback (most recent call last):

  File "C:\GIS\Python\AddPoint\", line 47, in <module>


TypeError: sequence size must match size of the row



current code.

#import modules  
import arcpy  

arcpy.env.qualifiedFieldNames = False
pointFC = "Animal Sightings" #target point feature class Animal Sightings
parcel = "par"
parcel_lyr = 'parcel_lyr' 

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

point = arcpy.GetParameterAsText(0)  #click

for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):        
        x,y = prow[0]
del prow          
point1 = arcpy.Point(x, y)        
ptGeometry = arcpy.PointGeometry(point1)


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

fldList = ['Owner','SiteAddress',]        
fldDict ={}   
#Check that we only have one parcel and get the attributes from it      
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))>=1:        
    for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):        
        for w in range(len(fldList)):        
    del parrow 
    targetFields = ['Owner', 'SiteAddress', 'POINT_X', 'POINT_Y','SHAPE@XY']

    with arcpy.da.SearchCursor(pointFC,targetFields) as cursor: # loop through feature set  
        for row in cursor:
            row = [] 

del insCursor # delete insert cursor