Select to view content in your preferred language

I have a question about how to get the elevation of a point given latitude and longitude or x,z coordinates in Unity.

283
2
02-10-2025 11:09 PM
SamsungCampTCivil
New Contributor

Currently, online is loading the world map through API Key, and offline is generating terrain through .tpkx file and displaying it in Unity's Scene.
For road alignment,
I want to draw a 2D plane line and project it on the terrain to return the elevation value of each point,
and I want to check the elevation value of the corresponding location with latitude/longitude or x, z coordinates on Unity.
RayCast has accuracy issues when the displayed map is wide, so I am considering it as an alternative.

Is there a function that can be used in ArcGIS Maps SDK for Unity?

aaa.png

2 Replies
MichaelBranscomb
Esri Frequent Contributor

The solution will depend on what you want to do with the line and elevation points. For example, is it purely for display? In which case, you probably want to simply have the line draped on the elevation surface.

Or do you need the elevation values for another purpose, in which case you might consider using our (beta) elevation service to get the best resolution value for each point/location: Elevation service (beta) | Esri Developer REST APIs documentation.

A couple of things to consider:

  • The data loading within the view uses Levels of Detail (LoD) to get the best performance, therefore coarser LoD are loaded in the distance, and raycasts further away from the observer/camera will return the values from those coarser LoD. 
  • Visually, you may still want to effectively drape the line on the terrain, because if it's drawn at an absolute elevation determined by more accurate values for each vertex/point, then it may disappear beneath the surface of the terrain in some areas and appear to be raised above the surface in other areas. 
0 Kudos
JanikCodes
Occasional Contributor

I've build something similar because you cannot rely on external services. Arcgis has no real out-of-the-box solution so making a custom system worked for me.

Your raycasts are inaccurate because of the different LOD of the tiles which comes from difference ArcGisCamera positions & settings so how do you combat that?

Have a system update their raycast result and update your line at runtime. You don't need to do this every frame and there is a lot of optimization you can do like only executing this update logic if you're close.

0 Kudos