Select to view content in your preferred language

Assigning dates from a polygon to a point feature layer using Calculate Field

640
4
08-02-2023 08:37 AM
Labels (3)
MaryK
by
New Contributor II

Hello, I am trying to assign unique dates from a polygon layer to a point feature class based on an intersecting relationship. Here is some relevant info:

The polygon layer has about 600 different polygons.

The point feature class has about 3700 points. They do not all intersect the polygon layer.

The actual point feature class is restricted for editing (I cannot add fields, but I can manually calculate them).

I pulled some Arcade code from a similar post on here and ran it on different sized exports from the polygons and point FCs, and it worked perfectly. Now I am trying to use it on the real feature class points and its throwing the following error: 

ERROR 002717: Invalid Arcade expression, Arcade error: Table not found polygons, Script line: 2

Here is the script I adapted:

// define the polygons that the information will be transferred from 
var polygons = FeaturesetByName($datastore, "polygons")

// determine the polygon that intersects the current point 
var i_polygon = First(Intersects(polygons, $feature))

// return an arbitrary default value if no polygon is intersecting - may need to retype date into expression
if(i_polygon == null) { return "1/1/1995" }

// return the name of the Polygon field with the information to be transferred
return i_polygon.FIELDNAME

I'm confused because I can manually calculate field for the real points, and I can use the real polygon layer to transfer attributes to exported points, but when I try a code block calculation on the real points no matter the polygon layer it always throws the same error. Help? 

 

4 Replies
AngelaSchirck
Occasional Contributor III

It is not finding the "poloygons" layer in the datastore that you're referring to in the line: 

var polygons = FeaturesetByName($datastore, "polygons")

If you're doing this within ArcGIS pro, and the polygons feature is on the map, try replacing $datastore with $map and see if it finds the layer.

Also to consider: Is "polygons" the name of your polygon layer? Because the statement is expecting the name of the feature layer.

Also change FIELDNAME in the code to the actual name of the field where the date is stored.

0 Kudos
MaryK
by
New Contributor II

Thanks for your answer! I will try this when I finish processing some imagery. 

No, "polygons" and FIELDNAME are not the actual names, associated with the data, I used them as place holders. Thanks again!

0 Kudos
MaryK
by
New Contributor II

Hi again, sadly replacing $datastore with $map did not locate the layer. Error on line 2: object not found $map.

I tried this with the layer on the map, of course. Any other ideas?

0 Kudos
AngelaSchirck
Occasional Contributor III

I know the featuresetbyname function is very specific.  If your feature is 'Polygons' and you use 'polygons' it's going to throw an error.  Be sure the table name is the correct case.  I can't really think of anything else, but it does seem that the error is in the line where you're calling the "polygons" layer.

0 Kudos