i have a code that has two issues 1. only one point gets updated with the parcel attributes no other points get updated and 2. the insertRow i currently have does not work it give me .
basically i am trying to create multiple points that spatially joins the new created points to parcels and updates the points attributes based on what parcel the points are created i am not sure why i am getting the following error.
#import modules
import arcpy
# Allow overwrite
arcpy.env.overwriteOutput = True
arcpy.env.qualifiedFieldNames = False
# Script user input parameters
pointFC = "CCA
parcel = "Parcels1" #Taxparcels
arcpy.env.workspace = r"C:\Temp\Default.gdb"
parcel_lyr = 'parcel_lyr'
sjpoints = "C:\Temp\Default.gdb\sjpoints"
poly = "ACCOUNT_1"
Pnt = "Account"
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)
insCursor = arcpy.da.InsertCursor(pointFC,'SHAPE@XY') # create insert cursor
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",point)
#Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(point, parcel_lyr , sjpoints)
#arcpy.FeatureClassToFeatureClass_conversion(parcel_lyr, "C:\Temp\Default.gdb", "parcel_lyr")
# define the field list from the spatial join
sourceFieldsList = ["TARGET_FID", poly,"SiteAddress",'SiteNum_1', 'SiteStreet_1','SiteStreet_1','SiteNumSfx_1','Predir_1','Postdir_1', 'SiteCity_1', 'SiteZIP_1', 'OwnerName_1']
# define the field list to the original points
updateFieldsList = ["OID@", Pnt,"SiteAddres",'SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName']
# populate the dictionary from the polygon
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)}
with arcpy.da.UpdateCursor(point, updateFieldsList) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0]
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
updateRow = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
#arcpy.FeatureClassToFeatureClass_conversion(point, "C:\Temp\Default.gdb", "p_lyr")
with arcpy.da.SearchCursor(point,('Account','SiteAddres','SiteNum','StreetName', 'SiteStreet', 'SiteNumSfx','Predir', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName')) as cursor: # loop through feature set
for row in cursor:
row = []
insCursor.insertRow(row)
arcpy.RefreshActiveView()