[R-sig-Geo] DEM plot3D and overlay an aerial image

Michael Sumner mdsumner at gmail.com
Mon Oct 3 14:32:15 CEST 2016


On Mon, 3 Oct 2016 at 21:08 Mathieu Rajerison <mathieu.rajerison at gmail.com>
wrote:

> Hi R-List,
>
>
> I have a DEM on one hand, and on the other hand, I have an RGB aerial image
>
> I tried rasterVis and plot3D function, but I didn't find how to use the
> colors of my RGB aerial image.
>
> For the moment, I used rgl instead although it doesn't seem very
> appropriate for georeferenced data..
>
> Here's the RGL code :
>
> gruissan =
> stack("../MAISON/DATA/geo/raster/bdortho_marseille/marseille.tif")
>
> r = values(gruissan[[1]])/255
> g = values(gruissan[[2]])/255
> b = values(gruissan[[3]])/255
> col = rgb(r, g, b)
>
> library(rgl)
> persp3d(1:nrow(mnt), 1:ncol(mnt), values(mnt), col=col)
>
>
I find the results are much better to use rgl more directly, if you can
construct the quadmesh with the DEM you can then texture map an RGB image
(it has to be PNG) directly, and there's no need for either the resolution
(or even the coordinate systems) of the texture and the DEM to match.
Texture mapping basically creates a new set of coordinates  on the DEM
structure itself, something our spatial tools are generally not very good
at.  If you are only changing the colours of the DEM pixels you don't get
anywhere near as good a result if your image is higher resolution than the
DEM.

This doesn't seem to be used very often, and in fact texture mapping in rgl
is hard to get right - you can leave the shade3d() material colours at
their default setting for example.  (It's also hard to show off since
there's a limit to the WebGL export that can be bundled into a page. )

This sequence below (it was fully reproducible when I did it) shows the
required steps in all their detail. I've since put the quadmesh package on
CRAN that does simplify some of this a fair bit. I'd be happy to work up an
example if you provide links to a DEM and image.

https://gist.github.com/mdsumner/e131f6d73aa02d49c7fd3357d94d3ad1

Cheers, Mike.



> Best,
>
> Mathieu
>
>
>>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list