Select to view content in your preferred language

Get route m-value at point-clicked using Arcade?

4811
13
Jump to solution
03-05-2020 07:42 AM
NickHarvey
Frequent Contributor

Hi All - I see that it is possible to access x,y,z, & m values for a custom pop-up using Arcade. The code below appears to be working in ArcGIS Pro 2.5.0 per my route layer:

var line = Geometry($feature)
var paths = line.paths;
var startingpoint = paths[0][0];
return text(startingpoint)‍‍‍‍‍‍‍‍

However, I'm not yet understanding how to return the m-value for any point along the route that was clicked, rather than the centroid or endpoints.  The m-value I'm looking for appears in the pop-up panel at lower right in ArcGIS Pro 2.5.0 (see pic below). 

Any assistance appreciated!  

2 Solutions

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Nicholas Flett and nickharvey 

The limitation with Arcade is that you start off with the geometry you clicked on (you M-enabled line) and not the point location of where you clicked. Therefore, it is not possible to determine at which location of the line feature you clicked when using Arcade. The SDK should allow you to do this, although the complexity of the implementation will increase. 

View solution in original post

AyanPalit
Esri Regular Contributor

Updating this old thread for tracking and community documentation. Get route m-value at point-clicked is out of the box Pro function and doesn't require any custom code.

At ArcGIS Pro 2.4, the Navigation > Explore tool included this enhancement.  You can view m-values in a pop-up for a feature that contains measured values (m-values) in their geometries. The coordinate display at the bottom of the pop-up includes the m-value closest to the clicked location in the map or scene. For linear geometries, the value is calculated by interpolating between the nearest vertices. 

Pop-ups for M-aware features

Related thread Link with Screenshots.

There is also LRS Identify widget in Experience Builder for web apps.

FYI @KatyLewis 

Ayan Palit | Principal Consultant Esri

View solution in original post

0 Kudos
13 Replies
BenTurrell
Frequent Contributor

Hey Nick Harvey‌,

Try this:

var line = Geometry($feature)
var paths = line.paths;
var startingpoint = paths[0][0]["x"];
return text(startingpoint)

Thanks,

Ben


If this answer has helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

NickHarvey
Frequent Contributor

Thanks for chiming in Ben - You're right...I can get to the m-value for the starting point of the route by replacing "x" with "m" for example...But I'm chasing the m-value for any point along the route, as it appears at the bottom of the pop-up panel at 2.5.0 where the route is clicked.  My idea was to build a calculation(expression) in the pop-up which uses this m-value as a variable.  The m-value is being populated at the bottom of the pop-up panel.  I'm not understanding how to reference it into the pop-up body though (?). 

0 Kudos
by Anonymous User
Not applicable

Hi Nick,
Did you make any progress with this?
I'm writing the same expression for start, end and current m values.

var line = Geometry($feature)
var paths = line.paths;
var firstpoint = paths[0][0]["m"];
var lastpoint = paths[0][Count(paths[0])-1]["m"];
var currentpoint = paths

  • ["m"]
    return text(currentpoint)
  • But have no idea what to put in place of the * shown above.
    Is this even the correct approach to using M-values in pop-ups?

    0 Kudos
    NickHarvey
    Frequent Contributor

    Hey thanks for responding Nicholas - No progress sorry to say...Yeah, my guess is that it is not the right approach for retrieving m-values dynamically along the line because our Arcade expressions above each refer to a specific vertex (?).  As my picture above depicts - m-values do show up in the standard popup though (at bottom right)...I wonder about SDK (?)         

    0 Kudos
    XanderBakker
    Esri Esteemed Contributor

    Hi Nicholas Flett and nickharvey 

    The limitation with Arcade is that you start off with the geometry you clicked on (you M-enabled line) and not the point location of where you clicked. Therefore, it is not possible to determine at which location of the line feature you clicked when using Arcade. The SDK should allow you to do this, although the complexity of the implementation will increase. 

    JosephJordan
    Emerging Contributor

    This is FINALLY possible, with the addition of the $userInput profile variable!  Try this:

    var geom=Geometry($feature)
    var densegeom=Densify(geom, 1)
    var PTC=PointToCoordinate(densegeom, $userInput)
    var SegNum=PTC.segmentID
    var paths=densegeom.paths
    var POI = paths[0][SegNum];
    return round(POI.m,4)

    https://www.youtube.com/watch?v=dddZTpsOjY0

    KatyLewis
    Emerging Contributor

    This is gold!!! Thank you so much. Now users can click along a line and get the nearest m value.

    0 Kudos
    JosephJordan
    Emerging Contributor

    Right??! You bet!  I think ESRI has made experience widgets that work if you have Roads & Highways too....but this is nice because you don't have to click a special widget....can just make the Road ID and M value show in the regular pop up.

    0 Kudos
    DISIG
    by
    Regular Contributor

    Hello Nick,

    Hello everybody. I am trying to do the same dynamically in Argis Online.(my point geometry change, my m value change in the map context windows)

    I want to use the cut function to get the left length of an intersecting (or nearest) line with M value in a field.

    I will write more after testing all that.

    i have got to 90° rotate the result of a clip between the buffer of my point and the line.

    not easy...

     

    it quite works...

    /*
    récupérer le cumul par intersection du point avec l'arc.
    */
    var CurDep = $feature.ROUTE
    var CurBuffGeom =Extent(Buffer($feature, 2, 'meters'))
    var CurArcGeom = Back(Filter(FeatureSetById($map, /* tests_arcade - Test li */ "17f27378b8d-layer-3"),'route=@CurDep'))
    var CUTTER = rotate(Clip(CurArcGeom,CurBuffGeom),90)
    return LengthGeodetic(first(Cut(CurArcGeom, CUTTER)))

     

    note : replaced first with back (when i flip the cutter, 90° the left part is the end part of the line.)

    0 Kudos