3D maps in R
The purpose of this post is to show how make a 3D map using rayshader
. The idea is to use a DEM obtained from the SRTM mission (worldwide cover) or an available DEM from other National Institutions, such as Mexico’s National Institute of Statistics and Geography to obtain a 3D relief of the area of interest; and an RGB composite to overlay it on the relief. The cloudless RGB mosaic I am using in this post was obtained from Landsat-8 images and was produced using Google Earth Engine. Finally, a shapefile with the locations of two urban settlements in the area is loaded to show their location.
First load the libraries we are going to use.
Then, read the images.
Then, clip the rgb image values to the lower and upper 3 % quantiles so the image can be better appreciated.
Next, let’s transform the rgb into an array and the dem into matrix, so they can be rendered in 3D.
Extract the coordinates of the two human settlements used as reference (as numbers) and drop the geometry.
Afterward, do the 3d rendering with the rgb and dem layers and set additional parameters for the visualization. Subsequently, add the labels of the two localities.
Finally, save a snapshot of the 3d model.
The result:
3D map of Patzcuaro and Morelia surroundings in Michoacán, Mexico.
If you are familiar with the surrounding of Morelia, Michoacán, Mexico, you will immediatly recognize Patzcuaro and Cuitzeo lakes, as well as some hills, such as the Quinceo.