1

I have DEM ( Digital Elevation Model ) data, and I want to perform a representation of it, in the form of heatmap or 3d surface.

I have the data converted from the .img DEM using gdal_translate in the following format in plain text csv of near 5000 lines :

-60.9998590004517638,-34.3334731637644026,69,
-60.9995812226737613,-34.3334731637644026,69,
-60.9993034448957587,-34.3334731637644026,70,
-60.9990256671177633,-34.3334731637644026,71,
-60.9987478893397608,-34.3334731637644026,72,
-60.9984701115617582,-34.3334731637644026,72,
-60.9981923337837628,-34.3334731637644026,72,
-60.9979145560057603,-34.3334731637644026,73,
-60.9976367782277649,-34.3334731637644026,73,
-60.9973590004497623,-34.3334731637644026,73,
-60.9970812226717598,-34.3334731637644026,72,
-60.9968034448937644,-34.3334731637644026,73,
-60.9965256671157618,-34.3334731637644026,72,
-60.9962478893377593,-34.3334731637644026,72,
-60.9959701115597639,-34.3334731637644026,70,
-60.9956923337817614,-34.3334731637644026,69,
-60.9954145560037588,-34.3334731637644026,69,
-60.9951367782257634,-34.3334731637644026,71,
-60.9948590004477609,-34.3334731637644026,73,

I want to know how should I proceed to normalize the data ( if its neccesary ) and then represent it as heatmap and/or grid/surface interpolating it.

I do like this kind of representation:

enter image description here

enter image description here

Im a Python developer, and whilet Im not restricted to this language, matplotlib, pandas, and his friends are welcome for myself.

Even when I don't know this field I was trying using this code example from github to represent it and Im not sure if its the correct way to do it.

# Based on example from:
# https://github.com/kjordahl/SciPy2013/blob/master/examples/kauai.py

import os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from osgeo import gdal

import Image

gdal.UseExceptions()

DEM = gdal.Open("dem.tif")

DEM_Array = DEM.ReadAsArray()

DEM_ArrayM = np.ma.masked_equal(DEM_Array,DEM_Array==0)

i, j = np.where(DEM_ArrayM>0)

topo = DEM_ArrayM[0:max(i)+1, 0:max(j)+1]

fig = plt.figure(frameon=True)

plt.imshow(topo, cmap=cm.gist_earth)

plt.axis('off')

cbar = plt.colorbar(shrink=0.9)

cbar.set_label('meters')

plt.savefig('plot_name.png', dpi=300, bbox_inches='tight')

plt.show()
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • If R is useable for you read the original file (not the csv) with r <- raster::raster(file), then convert to mesh with qm <- quadmesh::quadmesh(r), then plot with library(rgl); shade3d(qm) – mdsumner Jun 27 '17 at 22:40
  • The easiest is probably to stick to the original raster format you had (.img), read the data directly as a numpy array (e.g. using rasterio), and plot the array with imshow or plot_surface – Loïc Dutrieux Jun 27 '17 at 23:11
  • Hi! Thanks for your reply. I like that way. Some questions about it. 1) Do you have any code examples to look at ? 2) Is it possible to plot the information already processed ? Because in some cases I do not have the original .img files. Thanks! – jrodriguezmonti Jun 28 '17 at 01:14
  • What you do with the data depends on how it should be presented / decimated. What are you trying to say about the terrain? – BradHards Jun 28 '17 at 09:24
  • I would like to colorize the elevation. Some colors the higher, some other colors the lower, and so on. I want to know how to treat the data before representing it. I want to do that, and represent it as surface and heatmap. Thanks! – jrodriguezmonti Jun 28 '17 at 12:38