Creating a model to do Pairwise Intersect and set an Attribute Rule

262
0
01-17-2024 01:17 PM
Labels (1)
AndrewHiegel
New Contributor

I have 2 layers I am starting out with 

1.Harvest_TEST  (this is a timber harvest unit layer)

2.RoadBuffer_TEST (this is a layer that contains all the road buffers) 

Previously, I have been manually running a Pairwise Intersect with the two and then Calculating Geometry for the "roads" field in the new intersect layer (Hrvst_Rd_Intersect_TEST) to then manually inputing the updated road area in the Harvest_TEST layer. 

What I am currently trying to do is create a model that does this for me and sets an Attribute Rule to do an Immediate Calculation which pulls the updated road areas that were calculated in the Hrvst_Rd_Intersect_TEST layer and fills it into the matching road fields in the Harvest_Test layer. 

I know that I have to set Global IDs to the new Hrvst_Rd_Intersect_TEST layer after it is created in order to set an Attribute Rule. 

My problem is that sometimes after the intersect is done, there is an uneven amount of row in the attribute table between Harvest_TEST (6 rows) and Hrvst_Rd_Intersect_TEST (5 rows) (this occurs when there is no road along or within the harvest unit). I have been trying to run an Arcade script to do the Immediate Calculations using the code below, but I need to add a line in that tells it disregard the uneven number of rows. If that is not doable, how can I add a step in the model builder to have the Hrvst_Rd_Intersect_TEST layer have same number of rows as the Harvest_TEST layer but when no roads are present, it auto fills the field to 0. 

Is this possible or should I be using a totally different Geoprocessing tool to combine the datasets (Harvest_Test and RoadBuffer_TEST)?

*OBJECTID is the same in Harvest_Test layer and Hrvt_Rd_Intersect_TEST layer. I am using this as my identifier. 

 

var sourceTable = FeatureSetByName($datastore,"Hrvst_Rd_Intersect_TEST", ["OBJECTID", "roads"], false)

var matchedFeature = First(Filter(sourceTable, "OBJECTID = $feature.OBJECTID"))

If (matchedFeature == null){

    return "not found"}

else{

    return matchedFeature.matchedFeature.roads}

 

 

Model.PNG

0 Kudos
0 Replies