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 .
line 63, in <module>
insCursor.insertRow(row)
TypeError: sequence size must match size of the row
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.
line 63, in <module>
insCursor.insertRow(row)
TypeError: sequence size must match size of the row
I have checked to see if the "point" is being updated by the updatecursor with arcpy.FeatureClassToFeatureClass_conversion(point, "C:\Temp\Default.gdb", "p_lyr") after updateRows.updateRow(updateRow) and it looks like only one point gets updated.Separate question, Can i use the SpatialJoin to "In_memory" instead of to a gdb?I would really appreciate some help please.working with.#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
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()
Looking at this again, I'm not sure I'm on the right track. I see you've got a couple cursors open and I can't follow what the goal is. Could you please clarify (maybe with a screenshot) what exactly you're trying to do here?
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.
This sounds like something that has been discussed many other times (three by you in the past month). Is this thread for 2CDSD 2C or Paco ALVAREZ?
I am paco
And I am done here.
I have tried to edit my original and my second post with firefox, explorer and Chrome and they all do the same thing. When i select the python text and click on insert syntax highlighting then select python it puts the code in python format but once i hit save reply it shows my post but it's back to plan text. WTH is going on?