Select to view content in your preferred language

Polygon with null values, I would like to populate null values with adjacent polygon values

665
2
10-11-2023 09:46 AM
JustinBernard1886
New Contributor III

Hello,

I have a polygon layer with a number of null values, and i would like to populate the values with the values from ajdacent polygons.  The tools that I found merely create a table, but I would like to incorporate a process into a model. 
Is there a tool or python script that would be able perform this?
I attached a small screenshot to see what i want to do, the shape with no values are circled.

Regards,

Justin

0 Kudos
2 Replies
gis_KIWI4
Occasional Contributor II

@JustinBernard1886 - I believe you can do this by using the 'Calculate Field' and an Arcade Expression. 

I have mocked up a test 

gis_KIWI4_1-1700795583708.png

 

The Arcade Expression updates all the null values with an attribute from the touching polygon.
Update your Layer Name (TEST in my example) and Field Name (my field name was FIELD_A)

Var calculated_result = ""
Var touching_polygons = Intersects (FeatureSetByName($datastore, "TEST"),$feature)
Var Cnt = Count(touching_polygons)
If ( IsEmpty($feature.FIELD_A) && Cnt > 1)

{
  For ( var every_polygon in touching_polygons)
  {
     calculated_result = every_polygon.FIELD_A
     return calculated_result
  }
}

return $feature.FIELD_A

Output 

gis_KIWI4_2-1700796001462.png

 

Hope this helps. 

 

 

 

 

 

0 Kudos
DuncanHornby
MVP Notable Contributor

@gis_KIWI4 offers a solution that will guarantee that empty polygons are given a value, but which one? In their screen shot there are clearly two polygons adjacent to polygons with differing values. So as the code runs now it simply overwrites with the last visited polygon.

If that is sufficient then OK but you might want to explore the Polygon Neighbours tool to help quantify the importance of adjacency by shared boundary length?

0 Kudos