Group Abstract Group Abstract

Message Boards Message Boards

How can I extract the height of a DEM point?

I have a DEM that makes a fine picture when I use the Input function

Import[ "C:\\GIS \
Louisiana\\30091472_Plaquemines_NE\\3009147ne_dem\\dem_3009147ne.dem"]

I wish to test/manipulate the elevations at a set of sample locations. I've looked at the elements imported but cannot figure out how to query the elevation data for one location (pixel).

Import[ "C:\\GIS \
Louisiana\\30091472_Plaquemines_NE\\3009147ne_dem\\dem_3009147ne.dem","Elements"]

Any guidance very appreciated.

JAC

11 Replies
Posted 11 years ago
POSTED BY: Jim Baldwin
POSTED BY: David Reiss

If you search in the Mathematica documentation for "DEM" you will see options for reading the data and metadata, which you will probably know how to interpret. In this example I am just using pixel count for the coordinates of the x and y axes, since I don't know how to convert to lat and long. Tooltip is used to display the elevation, when the cursor is put over a contour line. This is not quite what you want, but close.

file = "/Users/christopherpurcell/Desktop/dem_3009147ne.dem";
 data = Import[file, "CoordinateSystemInformation"] 
 bounds = 
 Import[file, 
  "SpatialRange"]  (* should be {lat, long} in dec degrees but must \
be something else, maybe meters *)
 data = Import[file, "Data"];
size = Import[file, "Dimensions"]  (* data array size *)
 interp = ListInterpolation[Transpose[data]];
ContourPlot[ 
 Tooltip[interp[x, y]], {x, 1, size[[2]]}, {y, 1, size[[1]]}, 
 Contours -> Range[10], PlotPoints -> 50]

The next step might be to put a ReliefPlot of the data in a Manipulate, and return the elevation value that corresponds to the cursor location. Something along these lines, where if you click on a point, you get a display of the elevation in meters. (I think).

Manipulate[ 
 ReliefPlot[ data , FrameTicks -> True, 
  PlotLabel -> ToString[Join[x, {interp[Apply[Sequence, x]]}]], 
  ColorFunction -> "LightTerrain", 
  PlotLegends -> Automatic], {{x, {1, 1}}, Locator}]

Next you would figure out the lat and long and use DataRange option to get the axes scaled correctly.

Do any of the WRI developers on the forum have any advice for Mr. Cavell? The main issue is, given a DEM file, read it in and generate a function height[latitude,longitude] based on an interpolation of the supplied grid data in the DEM file. The two things that need to be extracted and analyzed for this are

a) the latitude and longitude range of the DEM array data b) any transformations that need to be done on the data based on the map projection indicated in the DEM file

It would be a good addition to DEM import if such a function could be generated as one of the import Elements for DEM

POSTED BY: David Reiss

It seems I've hit a dead-end. I just wish I was able to take apart the pieces that are obviously present to enable the graphical representation, but it seems "over my head." Perhaps reverting to something other than Mathematica will provide an answer.

JAC

Thanks for looking into this. The subject file (dem_3009147ne.dem) is attached. I have also tried to do something similar with embedded elevation models, also with no joy so I am trying with a local file. An example of a previous attempt is:

GeoGraphics[{EdgeForm[Black],GeoStyling["ReliefMap"],Polygon[=East Baton Rouge Parish]}, GeoBackground -> None]

(The = in front of "East Baton Rouge Parish" is ctrl-=.)

JAC

Attachments:

Could you attach your example file so that we have a chance to play with it and see what we can suggest?

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard