How to find elevation given latitude and longitude

1274
3
12-12-2018 04:55 PM
PeterStephens
New Contributor

How do I find elevation of a point given its latitude and longitude using ArcGIS runtime for Java?  I am loading the Basemap "Basemap.createTopographic()".  Does this give elevation data?  Is there an API call that can give the elevation given the latitude and longitude?  I am new to ArcGIS programming.  Thanks!

0 Kudos
3 Replies
santiagomonedero
New Contributor II

In .net 10.27 you can do something like this:

var height=await MyLocalElevationSource.GetElevationAsync(lon, lat, SpatialReferences.Wgs84));

probably in Java is similar.  Hope it helps.

PeterStephens
New Contributor

Hi Santiago,

Thanks for the reply.  Since I wrote the question, I figured a few things out.  I found the Java call that should be like the .net call that you refer to in your reply.  Basically, I am doing this ...

         Point p = new Point(llePoint.get(1), llePoint.get(0), wgs84);

         ListenableFuture<Double> d = surface.getElevationAsync(p);

This returns a value, but it is of the form ...

         com.esri.arcgisruntime.mapping.Surface$2@45c928ed

I'm not sure what to do with this.  I have tried to find a way to convert it to a numerical value that I can use, but no luck.  Have you seen anything like this before?  The API is not too clear and there don't seem to be any examples.  In using .net what is the significance of "await"?  I am not a .net user (yet) but I am curious.

Thanks,

--Peter

0 Kudos
santiagomonedero
New Contributor II

Hi Peter,

The await in .Net means that it is an asynchronous call (the thread will query for elevation and wait for a response) . In your case it seems to be something similar: you have a variable that in the future may become a double. I dont know java but if you want to try I just googled a bit and I think you may need to do somehting like this. Try and let me know if it works.

 ListenableFuture<Double> myListeanbleFuture = surface.getElevationAsync(p);


 Futures.addCallback(myListeanbleFuture, new FutureCallback<double>() {
                public void onSuccess(double myHeight) {
                    //here you will have the double myHeight you are looking for 
                } 
            })

Notice that as I said this is asynchronous calls and not very fast so you can query some points but I do not think would be useful if you want to obtain a whole raster of heights.

Cheers

0 Kudos