I came across this thread when searching for the tool I have used several times in the past. It can update data based on spatial relationships as well as others. There is some setup involved, but it will do the trick.
https://solutions.arcgis.com/shared/help/attribute-assistant/
if ObjectIDVal in valueDict: for n in range (1,len(updateFieldsList)): updateRow = valueDict[ObjectIDVal][n-1] updateRows.updateRow(updateRow)
Create a Spatial Join to an in-memory output and then use the TargetFID of that output to join back to the polygon ObjectID. TargetFID 1 of the Spatial Join will match ObjectID 1 of the polygons.
Dictionaries are absolutely wonderful, but they rely on being able to link the correct two rows. From looking the code in the link, it doesn't seem to have anything to do with location, it's all based on the OBJECTID/FID field. You are assuming that OBJECTID 1 in the poly feature class is the polygon that overlaps OBJECTID 1 in the point feature class, which doesn't seem like a fair assumption at all. That is a nice piece of code though, and you could also simplify it a little bit: if ObjectIDVal in valueDict: for n in range (0,len(updateFieldsList)): updateRow[n+1] = valueDict[ObjectIDVal] updateRows.updateRow(updateRow)
if ObjectIDVal in valueDict: for n in range (0,len(updateFieldsList)): updateRow[n+1] = valueDict[ObjectIDVal] updateRows.updateRow(updateRow)
Look at this post for the basic dictionary transfer code.
Might be quite time consuming but preferable to creating a new layer.
In python...1. Add fields for each attribute you want to transfer to the point feature class. Lets say you want to transfer two attributes from the polygon you would add those two fields to the point feature class.2. Loop through the polygons and select each polygon3. Save the two attributes you want to transfer to variables so they can be used later4. Do a select by location to select all the points within the selected polygon5. Use an update cursor to loop through the selected points and populate the two fields with the variables you created earlier
#make feature layer for point shapefile for row in arcpy.SearchCursor(polygon shapefile): #get FID and use it to construct a query that would only select the row (polygon) that you're looking at #make feature layer using that query so now you have a one-feature feature layer value = row.getValue("name of field you want a value from") #use this feature layer to make a select by location operation on the point layer you made above updaterows = arcpy.UpdateCursor(point feature layer) #the cursor should only contain the selected feature(s) for rw in updaterows: rw.setValue("field name you want to put the value in",value) updaterows.UpdateRow(rw)
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.