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\AddPoint_6.py", line 47, in <module>
insCursor.insertRow(row)
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 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]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
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)):
fldDict[fldList]=parrow
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 = []
row.append(fldDict['Owner'])
row.append(fldDict['SiteAddress'])
row.append(x)
row.append(y)
row.append(point1)
insCursor.insertRow(row)
del insCursor # delete insert cursor