Select to view content in your preferred language

How to know the altitude of a point?

245
4
a month ago
LuisSolaRuiz
New Contributor III

Hello!

Is there a way to know the altitude of a point knowing X and Y? 

I know there is a mapview function call .toMap(), which converts mouseEvent to Coordinates but not really useful in this situation. 

Thanks!

0 Kudos
4 Replies
JamesIng
New Contributor III

To work out the altitude or elevation of a point you can query the esri world elevation layer.

https://elevation.arcgis.com/arcgis/rest/services/WorldElevation/Terrain/ImageServer

There's a specific query you can do a fetch for which I've previously used:

Long story short - the query looks like:

https://elevation.arcgis.com/arcgis/rest/services/WorldElevation/Terrain/ImageServer/identify?f=json..."x":19650810.338719428,"y":-4569183.619518825,"spatialReference":{"wkid":102100,"latestWkid":3857}}&returnGeometry=false&returnCatalogItems=false&mosaicRule={"mosaicMethod":"esriMosaicLockRaster","ascending":false,"lockRasterIds":[1,2,15209,16975,18657,18658,18659,18660,32178,52532,78749,188453]}&geometryType=esriGeometryPoint&pixelSize={"x":0.0746455354095105,"y":0.07464553541110258,"spatialReference":{"wkid":102100,"latestWkid":3857}}&renderingRules=[{"rasterFunction":"Aspect"},{"rasterFunction":"Slope_Degrees"},{"rasterFunction":"Elevation_Feet"},{"rasterFunction":"none"}]&returnPixelValues=true&token=${token}

Where the geometry is your x,y co-ordinates you want to get information about, and token refers to your session token

This will return you an object that looks like:

 

{
    "objectId": 0,
    "name": "Pixel",
    "value": "176.691",
    "location": {
        "x": 19650810.338719428,
        "y": -4569183.619518825,
        "spatialReference": {
            "wkid": 102100,
            "latestWkid": 3857
        }
    },
    "properties": null,
    "catalogItems": null,
    "catalogItemVisibilities": [],
    "processedValues": [
        "71",
        "2",
        "579.694",
        "176.691"
    ]
}

 


The last value in the processValues is your elevation (in meters)

James from www.landkind.com
LuisSolaRuiz
New Contributor III

Hello @JamesIng! That was pretty useful!! 

I was testing it with different positions in our application and I came out with some questions. 

We are currently using 'world-elevation' value in the map ground property that use this service

 

ground: 'world-elevation'

 

For some reason, the serviced you used (left example) is returning better elevation than the supposed one (right example) :

LuisSolaRuiz_0-1716532800646.png

What do you think it can be? Also, I was wondering if I can request several altitude for several points...

Thanks for your help! 

0 Kudos
JamesIng
New Contributor III

@LuisSolaRuiz  Unfortunately I can't say with any real reason why one is returning better elevation, likely missing the pixelSize parameter which is used to figure out the size of the area for calculating the elevation.

Depending on what you're trying to achieve in your project - If you're working with a sceneView and wanting to get the elevation of multiple points you might actually be easier off using the queryElevation method on the ground layer

There's a couple of samples you can refer to:
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=elevation-query-points

This example shows how to get the elevation of mulitple points using the queryElevation method on a line.
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=elevation-query

Hope its helpful.

James from www.landkind.com
0 Kudos
LuisSolaRuiz
New Contributor III

@JamesIng, Thanks again for this useful information. 

I've been doing some test with this functionality and it is perfect to know exactly the altitude of a point in the Elevation Layer of my scene view. It really matches the layer and when I used it, the point is above the ground. 

So, this can be considered a solution, anyway, I still don't understand why when I query to the service that it's the same layer that I have in my scene view is returning different values 😞  It would be good to have both options because I will not have always a map loaded in the app to query it.

For that I've created another post Fetching to WorldElevation3D/Terrain3D is returning wrong altitude 

Let's see what it can be done. Thanks again

0 Kudos