gis - Better hillshading for map plots in R -


i'm working on improved hillshading topographical map plots. basic hillshade workflow documented in image() is:

require(raster) alt = getdata('alt', country='che') slope = terrain(alt, opt='slope') aspect = terrain(alt, opt='aspect') hill = hillshade(slope, aspect, 40, 270) plot(hill, col=grey(0:100/100), legend=false, main='switzerland') plot(alt, col=rainbow(25, alpha=0.35), add=true) 

this image shows plot(hill..) before plot(alt..) applied:

enter image description here

the method creates solid grey under-layer of hillshades on other data layers (e.g. elevation shading) plotted semi-transparently. problem approach (a) neutral colour flat terrain (rbg (202,202,202), '#cacaca') severely shades whole model, (b) prevents multiple shade layering, such used 'swiss hillshade' approach.

i can imagine workaround converts rasters matrices , applies hillshading numerical multiplier brightness of other layers, doesn't seem elegant (although may wrong). wonder if has ideas or (preferably) experience in area? in advance.

no experience this, why not give gray undermap alpha value depends on slopes? here's try:

# before require(raster) alt = getdata('alt', country='che') slope = terrain(alt, opt='slope') aspect = terrain(alt, opt='aspect') hill = hillshade(slope, aspect, 40, 270) plot(hill, col=grey(0:100/100), legend=false, main='switzerland') plot(alt, col=rainbow(25, alpha=0.35), add=true) 

enter image description here

as say, dark.

# after grayalphas <- seq(-1,1,by=.01)^2*100 grayalphas[grayalphas==100] <- 99 plot(hill, col=paste0(grey(0:100/100),sprintf("%.2d",grayalphas)), legend=false, main='switzerland')  plot(alt, col=rainbow(25, alpha=0.35), add=true) 

enter image description here

i set gray alphas have parabolic shape, minimum gray value .5 , max of 99 @ gray values of 0 or 1. if choose this, you'll want tinker levels, etc, easy implement. plus you'll want put more effort did alphas, mine strictly numeric , not hex.

[edit] found nifty function adding alphas, addtrans() here in sacha epskamp's answer. keeps parabola, ranges 0 in middle 255 on extremes.

grayalphas <- seq(-1,1,length=101)^2*255 plot(hill, col=addtrans(grey(0:100/100),grayalphas), legend=false, main='switzerland') plot(alt, col=rainbow(25, alpha=0.35), add=true) 

enter image description here


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -