Select to view content in your preferred language

Field calculates point intersecting polygon

532
2
a week ago
TL2
by
Frequent Contributor

Is there a simple day to grab attribute data from a polygon fc that intersects with a point fc.  I need to update points based on what polygon layer name they intersect. 

Right now, I am doing a spatial query and then attempting to field calculate but I feel like there is an easier way.

I need to do this in an AGO notebook but here is my arcade expression

var inter_trust = count(Intersects($feature, trust))

if (inter_trust > 0) 
{
return "Trust";
}
0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi @TL2, here is an example on how to do an intersect using the ArcGIS API for Python:

from arcgis.gis import GIS
from arcgis.geometry import filters

# Connect to AGOL
gis = GIS('home')

# Reference services
ptFeatureLayer = gis.content.get('cd10146a4a91477b928f0921957b9698')
polygonFeatureLayer = gis.content.get('c44daed09ff14f80b000b541653aa1fc')

# Get point layer
ptFeatures = ptFeatureLayer.layers[0]

# Get polygon layer
polygonFeatures = polygonFeatureLayer.layers[0]
polygonFeatureQuery = ptFeatures.query(where='1=1')

# Perform intersect
for polygon in polygonFeatureQuery:
    queryResult = ptFeatures.query(where='1=1', out_fields="division", geometry_filter=filters.intersects(polygon.geometry))
    division = queryResult.features[0].attributes['division']
    print(division)
0 Kudos
f92k
by
Occasional Contributor

You can join points and polygons to get attribute data based on location. See arcgis.features.GeoAccessor.join. Also, here is an example where points are joined to polygons from the Python API documentation: Example: Merging State Statistics Information with Cities. This should be applicable to your situation.

0 Kudos