tanaka package has been released on CRAN. This package is a simplified implementation of the Tanaka method.
Also called “relief contours method”, “illuminated contour method” or “shaded contour lines method”, the Tanaka method enhances the representation of topography on a map using shaded contour lines.
North-west white contours represent illuminated topography and south-east black contours represent shaded topography.
tanaka is a small package with only two functions:
tanaka()uses a raster object and displays the map directly;
tanaka_contour()builds the isopleth polygon layer.
This is a typical example of the package usage based on the dataset shipped with the package.
library(tanaka) library(raster) ras <- raster(system.file("grd/elev.grd", package = "tanaka")) tanaka(x = ras, breaks = seq(80,400,20), legend.pos = "topright", legend.title = "Elevation\n(meters)")
In the second example, the
elevatr package is used to download an elevation raster on a specific area. Then the
tanaka_contour() function is used to create an isopleth layer and finally the
tanaka()function is used to to display the map with a custom color palette.
library(tanaka) library(elevatr) # use elevatr to get elevation data ras <- get_elev_raster( locations = data.frame( x = c(6.7, 7), y = c(45.8,46) ), z = 10, prj = "+init=epsg:4326", clip = "locations" ) # create the isopleth layer iso <- tanaka_contour( x = ras, breaks = seq(500,4800,250) ) # display the isopleth layer plot(st_geometry(iso))
# create a custom color palette pal <- colorRampPalette(colors = c("#F9D3A1", "#1E315B")) # display the map tanaka(iso, col = pal(nrow(iso)))
The last example illustrates the use of
tanaka with non-topographical data. This map is based on the Global Human Settlement Population Grid (1km).