Select to view content in your preferred language

How to get elevation by a "click" event

4483
4
09-24-2015 01:52 PM
TimWang
New Contributor

I was trying to develop a web application using ArcGIS API and Javasrcipt. I need to get the elevation value using a click event. I found an example for getting a elevation profile (see code below),

map.on("load", init);
function init() {
  var eleList = ["Polyline", "FreehandPolyline"];
  for (var ele in eleList) {
  on(dom.byId(eleList[ele]), "click", function (evt) {
  initToolbar(evt.target.id.toLowerCase());
  });
  }

but I could not find a sample to get elevation for a point location.

There is some description about this function at: https://developers.arcgis.com/rest/elevation/api-reference/summarize-elevation.htm, but I have no idea how to use it. Any help is appreciated.

4 Replies
BrianLocke
Occasional Contributor II

Well it depends on how you want to do it.  One of the ways that I have done it in the past is to do an Identify against a DEM  image service layer.  The cell value that is returned will give your elevation (potentially check metadata for whatever Image Service DEM you may be using).  Secondly if you look at the GP Service that you've mention above the input parameters will except the geometry type of point.  I would pass the Point geometry data type instead of the Polyline.  I would check into seeing if using elevation services takes credits BTW.  Things like routing and analysis for certain things may require the use of credits.  I am not sure about the elevation services but I would check into that.

0 Kudos
TimWang
New Contributor

Thanks, Brian. It is helpful. Could you explain more about the first option (the second option charge credit). Ho to do  an Identify against a DEM image service layer? Is it possible to load DEM kml layer to get elevation?

0 Kudos
BrianLocke
Occasional Contributor II

So where I would first start out is by looking at the API for Image Service Identify Task.  This will get you pretty far.  Basically Queries and Identifies have two parts.  First we have the Parameters and then we have the tasks.  You will first set up your Parameters (See the ImageServiceIdentifyParameters within the API) The Parameters property geometry will contain the MapPoint as your Identify Point.  Next we create the Task and then execute that task passing it the newly created ImageServiceIdentifyParameters.  You will need to find an Image Service Layer.  There are many out there and they may all have different levels of accuracy or cell sizes.

identifyParams = new ImageServiceIdentifyParameters();


identifyTask = new ImageServiceIdentifyTask("THIS WILL BE THE URI OF YOUR IMAGE SERVICE");

"Click", identifyElevation);



identifyElevation(e) {

showElevation(results) {

//Here is where you would process your results look at the ImageServiceIdentifyResult

};

Tim Wang wrote:

Thanks, Brian. It is helpful. Could you explain more about the first option (the second option charge credit). Ho to do  an Identify against a DEM image service layer? Is it possible to load DEM kml layer to get elevation?

0 Kudos
BrianLocke
Occasional Contributor II

for each vertex in the polyline I would just fire off another query

0 Kudos