[R-sig-Geo] rasterVis, multiple plots and scalebar labels

Ben Tupper btupper at bigelow.org
Fri Sep 23 18:11:00 CEST 2016


Hi,

I would like to specify the labels drawn on the scalebar for a multi-raster plot.  I have seen this exchange (and try to replicate for multiple rasters below)  

https://stat.ethz.ch/pipermail/r-help/2011-August/286705.html

I can't make that work with rasterVis::levelplot()

# start preparatory
library(raster)
library(rasterVis)

x <- raster::raster(volcano,
	crs = '+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0',
	xmn = -45, xmx = -40, ymn = 39, ymx = 47)  
xx <- addLayer(x,x,x)

at <- seq(90, 200, length = 10)
labels <- rep(" ", length(at))
labels[1] <- "low"
labels[length(labels)] <- "high"
# end preparatory

# try as in help exchange above - ticks are labeled with numerics
rasterVis::levelplot(xx,
     colorkey = list(at = at),
     labels = list(labels = labels, at = at) )

# try as described in ?rasterVis::levelplot section for labels
# ticks still labeled with numerics
rasterVis::levelplot(xx,
	at = at,
 	labels = labels )

I'm stumped!  How do I control the tick labels on a scalebar?

Thanks!
Ben


> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rasterVis_0.40      latticeExtra_0.6-28 RColorBrewer_1.1-2  lattice_0.20-33    
[5] raster_2.5-8        sp_1.2-3           

loaded via a namespace (and not attached):
[1] zoo_1.7-13        rgdal_1.1-10      parallel_3.3.1    hexbin_1.27.1    
[5] Rcpp_0.12.6       grid_3.3.1        viridisLite_0.1.3


Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org



More information about the R-sig-Geo mailing list