Select to view content in your preferred language

Arcade expression to get Start X and Y from a polyline

1408
5
Jump to solution
02-16-2023 02:19 AM
Labels (1)
cat206
by
Frequent Contributor

I'm starting to learn a bit of Arcade but very new to it, and looking at creating an attribute expression to create a short cut link in my pop up to my companies video survey which the URL uses x and y.

I have managed to correctly enable this for point features using the below:

var PointGeometry = Geometry($feature);
var ArcadeX = PointGeometry.x;
var ArcadeY = PointGeometry.y;

but I would like to use it for Polyline, by getting the start point x and y, can anyone help please?

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

If you look at the the contents of a polyline, you see this:

{"spatialReference":{"latestWkid":3857,"wkid":102100},"paths":[[[-9834291.023,5119236.579900004],...,[-9834888.189,5118479.376900002]]]}

So we can just use .paths on our feature to get the array, and then grab the first point of the first line.

var first_point = Point(First(Geometry($feature).paths[0]))

return `first vertex x: ${first_point.x}, y: ${first_point.y}`

jcarlson_0-1676554183932.png

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
5 Replies
AngelaSchirck
Frequent Contributor
0 Kudos
jcarlson
MVP Esteemed Contributor

If you look at the the contents of a polyline, you see this:

{"spatialReference":{"latestWkid":3857,"wkid":102100},"paths":[[[-9834291.023,5119236.579900004],...,[-9834888.189,5118479.376900002]]]}

So we can just use .paths on our feature to get the array, and then grab the first point of the first line.

var first_point = Point(First(Geometry($feature).paths[0]))

return `first vertex x: ${first_point.x}, y: ${first_point.y}`

jcarlson_0-1676554183932.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
cat206
by
Frequent Contributor

This worked perfectly, thank you!

0 Kudos
Bud
by
Esteemed Contributor
0 Kudos
jcarlson
MVP Esteemed Contributor

I seem to recall saving Arcade expressions at an organizational level is on the roadmap, right? I wonder if that could open the door something like org-wide custom functions, to just define our own Endpoint function and reuse it, rather than holding our breath on the next Arcade update.

- Josh Carlson
Kendall County GIS