Select to view content in your preferred language

Arcade expression to calculate fields based on what is to the right and left side of a polyline?

322
5
08-16-2024 04:06 PM
CayerA
by
Occasional Contributor

Hi,

I am in the process of adding attribute rules to our road centerlines in order to speed up the editing workflow. I know how to use Arcade to calculate fields from overlapping features, but is there a way to calculate a field differently depending on what is to the left or right of the polyline? For example, the feature class has a few sets of fields to denote the left and right hand side of each centerline ('L_ZIP', 'R_ZIP', 'L_JURIS', 'R_JURIS', etc). More often than not, these fields match for any given road, however there are segments that either straddle or run closely parallel to those boundaries and the two related values differ. The screenshot below shows an example of an area where this would be applicable for both zipcode and jurisdiction on NE 192nd Ave. Zipcode 1 (indicated by blue boundary line) and city (indicated by beige fill) on the left, zipcode 2 and unincorporated county (white background) on the right.

Is it possible to write an expression to check the zip code/jurisdiction a specified distance in both directions and return that value?

CayerA_0-1723849215522.png

 

0 Kudos
5 Replies
DavidSolari
Frequent Contributor

Does NearestCoordinate work for your use case? This requires Pro 3.3 and/or Enterprise 11.3 but it looks like it returns the side info.

0 Kudos
CayerA
by
Occasional Contributor

I was looking at that, but I wasn't exactly sure how to return the proper result. Our org is still at 3.1 for now, so I'd have to test it on a machine that has 3.3 installed. Here's what I've come up with in the Playground. Can you tell me if I'm headed in the right direction?

 

var zip = FeatureSetByName($datastore, "Transportation.xyzx.ZipCodeVW", ["ZIPCODE"]);
var Result = NearestCoordinate(zip, Buffer($feature, 100, 'feet'));
if (Result.left != Result.right) {
return Result.left  
}
0 Kudos
DavidSolari
Frequent Contributor

My org's in the same boat so I can't tell you what the proper process is. Based on the docs I think the first parameter is the line geometry to test against and the second parameter is a point. You might have to intersect the buffered line against the points to get a sensible set, run NearestCoordinate against every point, find the closest one, then use that for your results.

0 Kudos
KenBuja
MVP Esteemed Contributor

It looks like there are a couple of things wrong with this code. NearestCoordinate takes a single feature as the first parameter, but you're providing a FeatureSet. You'd have to get a single feature from zip as the first parameter. It takes a point as its second parameter, not a polygon (the result of a Buffer function). Finally, the return contains the property sideOfLine, not left or right.

Your code would look something like this:

var zip = First(FeatureSetByName($datastore, "Transportation.xyzx.ZipCodeVW", ["ZIPCODE"])); //or you could filter the featureset for a specific zip and get the first item from that
var Result = NearestCoordinate(zip, $feature);
return Result.sideOfLine

 

0 Kudos
TedHoward2
Esri Contributor

Just posted a similar answer here. You can offset the line by a certain distance, find the midpoint, and then perform an intersect.