Select to view content in your preferred language

Arcade Intersection between two points

1228
5
Jump to solution
12-30-2022 09:33 AM
KWilliams
Occasional Contributor

Hello,

I have a Field Maps project that is requiring some Arcade writing. Our fielders want the name of a line to be auto-populated. We are working in utilities. The fielders are going down a street, adding a pole/point feature, naming it, move on - next pole/point feature, naming it - then draw a polyline/span connecting the two. The ask is that the polyline/span will auto-populate the Span to be "name of pole - name of pole". Example: first pole is 12345, second pole is pole number 12346, so the span will be 12345-12346.

I'm aware of Intersect, I have used that before to populate data from a singular entity onto another intersecting entity. I've hit a mental block with this question because these are two points being used to intersect one line. 

I attached a screenshot as an example. 

Any help would be greatly appreciated.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
MarkBockenhauer
Esri Regular Contributor

using Attribute Rules you could do something along the lines of this:

var pole = FeatureSetbyName($datastore,"points",["Name"])
var line = buffer($feature,.1)
var ab = Intersects(pole, line)
var line_name = ''
for (var a in ab){
var pole_name = DomainName(a, "Name")
line_name += pole_name +'-'}
return left(line_name, count(line_name)-1);

You could also calculate the values after the fact, if you are not able to use attribute rules (e.x. using ArcGIS Online Hosted Feature Layers)

The is what it looks like labeling the created features in ArcGIS Pro

MarkBockenhauer_0-1672430617278.png

 

View solution in original post

0 Kudos
5 Replies
MarkBockenhauer
Esri Regular Contributor

using Attribute Rules you could do something along the lines of this:

var pole = FeatureSetbyName($datastore,"points",["Name"])
var line = buffer($feature,.1)
var ab = Intersects(pole, line)
var line_name = ''
for (var a in ab){
var pole_name = DomainName(a, "Name")
line_name += pole_name +'-'}
return left(line_name, count(line_name)-1);

You could also calculate the values after the fact, if you are not able to use attribute rules (e.x. using ArcGIS Online Hosted Feature Layers)

The is what it looks like labeling the created features in ArcGIS Pro

MarkBockenhauer_0-1672430617278.png

 

0 Kudos
KWilliams
Occasional Contributor

Thank you for taking the time to look at my question. I am using AGOL hosted feature layers. I will need to run this on the backend. I will save that code for future use. Thank you!!

0 Kudos
Adam_Bourque
Regular Contributor

Trying not to use attribute rule for online-live layers. Can either of you elaborate how to get this code to work with calculation on an layer in AGOL? I tried both in Pro as field calculate and AGOL calculate. Keep getting error on line1 not finding the layer..  @MarkBockenhauer @KWilliams 

0 Kudos
KWilliams
Occasional Contributor

@Adam_Bourque,

Because I was using an AGOL hosted feature layer, I was not able to use to the code provided by Mark to set up the calculation to happen during field collection. Instead I came up with my own solution in ArcPro when post-processing the data. I also did not set up the attribute rules as suggested because this was a one time process. What I did do, I hope its not too wordy:

  1. Download all AGOL layers to local, save to geodatabase
  2. Spatial Join my Poles (Join Features) to my Spans (Target Features), Join one to many, Match Option: Intersect
  3. From Output lines feature, run summary statistics on Target_FID to see how many points each line segment intersects with; Field: OBJECTID, Statistic Type: Count, Case Field: TARGET_FID. Output will be for each ObjectID, provide the total count of TARGET_FID per single ObjectID (Most will be 2, some will be 3+) (keep in mind I am working with poles and the lines between the poles). Def query your output lines feature to where Target_FID count = 2 for the next few steps. 
  4. From Output feature, run summary statistics on Target_FID again, this time get minimum Target_FID. Output will be for each ObjectID, provide the minimum Target_FID. So where the line intersects with two+ points, the summary will provide you the lower value. Save that summary statistic in map.
  5. Likewise, run the same tool but get the maximum Target_FID. So where the line intersects with two +points, the summary will provide you with the higher value. Save the summary statistic in map. 
  6. You now have the following: where your line file intersects with two points, you have the ObjectID of each point. 
  7. I'm not sure how to run this for 3+ intersections, I did those manually.
  8. On your original, unjoined line file, add the field: ID (or whatever you're using), table join this with the summary statistic minimum using ObjectID, then field calculate over that minimum value. Remove join
  9. Rerun that table join but instead join to the summary statistic maximum using ObjectID, then field calculate over the maximum value, adding a - (dash) in the middle.
  10. Remove join. Now for each line that intersects with two points, you have the concatenated ObjectID-ObjectID.

 

I hope that helps! 

0 Kudos
Adam_Bourque
Regular Contributor

Thanks @KWilliams I will end up using this method like I have similarly before if I can't get an arcade expression to work.

0 Kudos