Hi all,
I have a point layer with 15 attributes.
I digitized a polygon layer - one polygon around each point.
How can I transfer/assign all attributes from the point layer to the polygon layer, based on point completely within polygon?
Thanks.
Solved! Go to Solution.
So, just to be clear: the fields don't currently exist on the polygon layer? If that's the case, you may as well do a spatial join. Either do the GP tool and save the new output, or else do the right-click spatial join and save the result to a new layer.
In terms of automation, there are ways to copy portions of one layer's schema to another, but that really only needs to be done once. If your layers are in a geodatabase and you can take advantage of Attribute Rules, the same expressions posted earlier for calculating fields could be used to populate a polygon's attributes automatically if it were drawn around an existing point.
Try spatial join?
Assuming the fields had the same names, a Field Calculation could use a spatial operation using Arcade.
var pts = FeatureSetByName($map, 'your points layer name')
// get the intersecting point
var pt = First(Intersects($feature, pts))
return pt['field name']
You'd have to re-run it for every field, though.
How many point/polygon pairs are we talking about here? You could use the Transfer Attributes tool in the Modify Features pane, then it's just
For each pair. If the field names are different, you can open up the editing settings and define the field mapping between the two layers.
For each of the attributes, run the Calculate Field tool on your polygon fc. Switch to Arcade, copy and edit the code below.
// load your points
var point_fc = FeatureSetByName($datastore, "NameOfYourPointFC")
// get the point contained by the polygon
var contained_point = First(Contains($feature, point_fc))
// return null if there is no point
if(contained_point == null) return null
// else return the point's attribute
return contained_point.FieldName
Thanks all. My points is not to have to create the attribute fields on the polygon layer manually. Possibly it can be automated...
Spatial join - I was thinking about this. Do you mean the tool in the toolbox or the right-click>join potion on the layer?
So, just to be clear: the fields don't currently exist on the polygon layer? If that's the case, you may as well do a spatial join. Either do the GP tool and save the new output, or else do the right-click spatial join and save the result to a new layer.
In terms of automation, there are ways to copy portions of one layer's schema to another, but that really only needs to be done once. If your layers are in a geodatabase and you can take advantage of Attribute Rules, the same expressions posted earlier for calculating fields could be used to populate a polygon's attributes automatically if it were drawn around an existing point.