I have a simple desktop app with a map control. The map data that will be available to show will be either DTED files (Military Analyst's catalog / MADTEDLayer), or GeoTiffs (created by gdal). I want the user to be able to continuously see the elevation under the position of the mouse cursor. Is it possible to extract this information from the map layer somehow?

PS. I suppose that GeoTiffs have some kind of elevation data embedded since I opened them with GlobalMapper and saw height information under cursor.

  • You mean as the mouse moves, the elevation will update without the user clicking the mouse? – Kirk Kuykendall Sep 19 '11 at 22:07
  • Yes, although this is not the problem. I want to have the elevation data at a given point, no matter if it is right/left click or mouse motion. – Exile79 Sep 19 '11 at 22:11

I think you should be able to cast the layer to an IFeatureLayer, fetch each polygon (raster footprint) that intersects the mouse location, then fetch the raster associated with that polygon.

The value of the "Raster" field can be cast as an IRasterValue2, which can then be passed to IRasterSurface.PutRaster. After that you can call ISurface.InterpolateShape. Caching this will certainly make it faster, though I'm not sure it would be fast enough to be usable with mouse move events.


enter image description here

Note how the IGG tools uses IRasterSurface, without having 3D analyst. It is just a regular rastercatalog though - not an MADted, but I don't think that would matter.

IFeature feat;
while ((feat = fCur.NextFeature()) != null)
    IRasterValue2 rval = feat.get_Value(idx) as IRasterValue2;
    IRasterSurface rSurf = new RasterSurfaceClass();
    sum += ((IRasterProps)rval.Raster).MeanCellSize().X;
    rSurf.PutRaster(rval.Raster, 0);
  • IRasterSurface is part of 3DAnalyst, for which I don't have license. I have the terrible feeling that I will have to get the actual color value of the specified point in the raster and calculate somehow myself the elevation but I really hope there is an elegant way to do this – Exile79 Sep 20 '11 at 8:32
  • Hmm, that's strange. It works for me in an arcmap 10.0 extension even though I'm not consuming a 3D analyst license. – Kirk Kuykendall Sep 20 '11 at 12:46
  • It's not strange, sure it works for developer license, but you have to pay FOR EACH deployment license, and that is a no-no situation for us (there will be many terminals) – Exile79 Sep 20 '11 at 14:04
  • 1
    Oh yeah, I am deploying this to someone who has 3D analyst. Instead of using IRasterSurface, you should be able to access IRasterValue2.Raster and get the value of the pixel using a pixel block. It can be done more simply than is shown in this example. – Kirk Kuykendall Sep 20 '11 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.