[edit]The tanaka
package, released after this post, facilitates the creation of such maps[/edit].
The following post, Tanaka method or how to make shaded contour lines on LandscapeArchaeology.org blog, explains clearly and thoroughly what shaded contour lines are and how to draw them with QGIS.
How hard would it be to implement this method with R?
This method is used to enhance the elevation visibility on raster images, so the first step consists in getting or building a raster image. Then we have to extract contour polygons. The last step consists in displaying successive layers of these contour polygons.
In this example I build a raster of the smoothed population density of Paris using IRIS units, which are a french sub-municipal statistical division.
Then I use the rasterToContourPoly()
function from SpatialPosition
to extract contour polygons based on the density raster.
I finally iterate over each levels of contour and plot three contour layers at each iteration: one with a north-west shift and a light color, a second with a south-east shift and a dark color, the third is plotted in place and colored according to the color palette.
Here is the final map on the smoothed population density in Paris:
You can find the full script used to build this map here.
The last map use the same technique on a more classical elevation dataset on Martinique.
Full script for this map here.
OpenEdition vous propose de citer ce billet de la manière suivante :
Timothée Giraud (12 juillet 2018). Shaded contour lines or Tanaka method with R. R Géomatique. Consulté le 9 décembre 2024 à l’adresse https://doi.org/10.58079/tp4e
Hello,
this is a great tool! Is there a chance that you update the Martinique map script? I get an error saying that the rasterToContourPoly() function is unknown. Using the isopoly() function, it gives an error as well, saying that the layer names are invalid.
Best wishes
Uli
Thank you.
Today I would rather use the tanaka package and the mapsf package.
See https://gist.github.com/rCarto/aade3fb2f6cb8d69557e4caa95b86c96#file-with_tanaka_pkg-r
Dear Timothee,
I saw that you suggest using the tanaka package. What I liked on the old script was that I could plot the data through base R. As far as I can see, the tanaka package has its own plotting function and I prefer adding just another layer to my existing plot using the “older” version.
Best wishes
Uli
All right, in that case I suggest you use only `tanaka_contour()` from tanaka package to get isocontours and use base plot it as in the former example.