[R-sig-Geo] alpha support in raster function 'KML'?

Tomislav Hengl hengl at spatial-analyst.net
Wed Apr 8 15:32:59 CEST 2015


Yes, you can set-up transparency using 'alpha' e.g.:

R> library(plotKML)
R> library(sp)
R> data(eberg_grid)
R> gridded(eberg_grid) <- ~x+y
R> proj4string(eberg_grid) <- CRS("+init=epsg:31467")
R> data(SAGA_pal)
R> kml(eberg_grid, colour=TWISRT6, alpha=.8, colour_scale = SAGA_pal[[1]])
KML file opened for writing...
Reprojecting to +proj=longlat +datum=WGS84 ...
Writing to KML...
Closing  eberg_grid.kml

But you can also just set opacity directly in Google Earth 
(https://www.youtube.com/watch?v=5HZ8Q82qcFI).

HTH,

T. (Tom) Hengl
Researcher @ ISRIC - World Soil Information
Team member Africa Soil Information Services http://africasoils.net
Url: http://www.wageningenur.nl/en/Persons/dr.-T-Tom-Hengl.htm
Network: http://profiles.google.com/tom.hengl
Publications: http://scholar.google.com/citations?user=2oYU7S8AAAAJ


On 8-4-2015 3:06, Gregovich, Dave P (DFG) wrote:
> Hello,
> Does the 'KML' function from the raster package support an alpha channel?
> The .kml file output via the code below suggests it does not, but I was hoping for confirmation.
> Thanks kindly.
> Dave.
>
> #__________________________________________________________
> library(raster)
> r <- raster(nrows=108, ncols=21, xmn=0, xmx=10)
> r[]<-rep(1:10,1000)[1:ncell(r)]
> t.colors <- colorRampPalette(colors = c('yellow','orange','red'),alpha=F)(10)
> t.colors <- paste(t.colors,c('1A','33','4D','73','8C','99','B3','CC','E6','FF'),sep='')
> KML(r, filename='c:/test/test.kml', blur = 3, col = t.colors, overwrite=T)
> #__________________________________________________________
>
> #salient sessionInfo()
> #R version 3.1.3 (2015-03-09)
> #Platform: x86_64-w64-mingw32/x64 (64-bit)
> #Running under: Windows 7 x64 (build 7601) Service Pack 1
> #other attached packages:
> #[1] dismo_1.0-12    plotKML_0.5-0   twostageRSF_1.1 debug_1.3.1     rgdal_0.9-2     raster_2.3-33   sp_1.0-17
>
>
> __________________________________
> Dave Gregovich
> Research Analyst
> Alaska Department of Fish and Game
> Wildlife Conservation Division
> Douglas, AK 99821
> (907) 465-4291
> dave.gregovich at alaska.gov
> __________________________________
>
>
> 	[[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
>



More information about the R-sig-Geo mailing list