Select to view content in your preferred language

How to use attribute rules with points & polygons

636
3
10-26-2023 07:54 AM
AndrewReynoldsDevon
Regular Contributor

I have a point layer of several points & several polygons. I need to link these by finding out all the points that are in x polygon. I need Pro to lookup the polygon that a point resides in & to write this value out. 

Example

Point A is in Polygon B. The output feature will be recorded as Polygon B.  

The code below returns a geometry error on line 4

The polygon layer is called ExportedCentreAreas which is stored in my personal geodb. 

 

error.JPG

 

// load the other featureset
var fs = FeatureSetByName($datastore, "ExportedCentreAreas")
// get the first feature from fs that intersects the current $feature
var f = First(Intersects(fs, $feature))
// abort if we didn't find something
if(f == null) { return }
// return the intersecting feature's value
return f.Children_s_Centre_Cluster

 

 

 

 

0 Kudos
3 Replies
tzz_12
by
Emerging Contributor

There are several ways to do this. I recommend creating a python script to be most efficient. You can use the select by location tool to select all the points within a specific polygon and export those feature out as a separate feature class (export to memory, if you don't want a feature class output). Then, you would use the table by table tool to export it out as the output type you desire (e.g. csv, stand-alone table, etc). This should only take a few lines in python, but you can also do it manually. You can do this in a loop if you need to do this for multiple polygons. 

0 Kudos
AndrewReynoldsDevon
Regular Contributor

The points are postcodes & the polygons are named areas. The end result I need to have is a list of postcodes which have looked up the named polygon that they reside in  then to add this value as a field called named polygon. Therefore it's more of a spatial lookup?

0 Kudos
AndrewReynoldsDevon
Regular Contributor

could attribute rules be used here?

0 Kudos