Hello,
I am trying to write polygon values to a point feature class based on an intersection of geometries.
My polygon feature class is called 'Locations' with the intended field to copy being 'Location'.
The point feature class is called 'Record'.
My two feature classes are hosted feature classes on AGOL, with the point being collected with Survey123.
I have started to try and do it through field calculating in ArcGIS Pro, but if it is possible in Data Pipelines or FME automatically taht would be good too
// 1. Connect to the polygon layer via Portal()
var polygonFS = FeatureSetByPortalItemId(
Portal(),
"YOUR_PORTAL_ITEM_ID_HERE", // Replace with your polygon layer's item ID
0 // Layer index (0 = first layer)
);
// 2. Find the polygon that intersects the current point feature
var matchedPolygon = First(Intersects(polygonFS, $feature));
// 3. Return the polygon's attribute value
if (IsEmpty(matchedPolygon)) {
return null; // No polygon found
} else {
return matchedPolygon["YOUR_POLYGON_FIELD_NAME"]; // Replace with your field name
}
Solved! Go to Solution.
getZone(!Shape!)
------------------------------------------------------
import arcpy
def getZone(point_geom):
polygon_layer = "polygon_layer" # just the layer name as it appears in ArcGIS Pro
with arcpy.da.SearchCursor(polygon_layer, ["SHAPE@", "field_name"]) as cursor:
for row in cursor:
if row[0].contains(point_geom):
return row[1]
return NoneCalculated the field using Python.
As you have posted your question in the ArcPro group I will assume you are seeking an Arcpro solution. Simply add the 2 layers to your map and run the Add Spatial Join tool and make sure Permanently Join Fields is checked on if you want the field from your polygon dataset to be permanently transferred into your point dataset.
getZone(!Shape!)
------------------------------------------------------
import arcpy
def getZone(point_geom):
polygon_layer = "polygon_layer" # just the layer name as it appears in ArcGIS Pro
with arcpy.da.SearchCursor(polygon_layer, ["SHAPE@", "field_name"]) as cursor:
for row in cursor:
if row[0].contains(point_geom):
return row[1]
return NoneCalculated the field using Python.