[R-sig-Geo] spplot: correct display of data minimum in colour key

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Jul 18 18:39:28 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Ulrich, please try the "at" argument of spplot; see the following
example on lattice::levelplot, for which spplot is a front-end:

xy = expand.grid(x=1:10,y=1:10)
xy$z = runif(100)
library(lattice)
levelplot(z~x+y,xy)
levelplot(z~x+y,xy,at=(0:10)/10)


On 07/18/2013 11:44 AM, ulrich.leopold at tudor.lu wrote:
> 
> Dear all,
> 
> I try to plot a raster map  with a correct colour key using spplot.
> But the minimum seems to be smaller than the data minimum in the
> colour key.
> 
> I use the following code:
> 
> ##  Summary of raster map
>> summary(slope.grid)
> Object of class SpatialGridDataFrame Coordinates: min      max x
> 76165.36 78140.36 y 65210.14 67560.14 Is projected: NA proj4string
> : [NA] Grid attributes: cellcentre.offset cellsize cells.dim x
> 76167.86        5       395 y          65212.64        5       470 
> Data attributes: Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
> NA's 0.00   19.37   31.72   34.97   48.95   83.57  131421
> 
> ## exact minimum
>> min(slope.grid$band1, na.rm = T)
> [1] 0.003956468
> 
> ## Plot Slope grid and sampling scheme l1 = list("sp.points",
> roeser.sp, pch = 21, lwd = 1, col = "black", fill = "white", cex =
> 0.8) l2 = list("SpatialPolygonsRescale", layout.north.arrow(),
> offset = c(76250,67200), scale = 300) l3 =
> list("SpatialPolygonsRescale", layout.scale.bar(), offset =
> c(77500,65300), scale = 500, fill=c("transparent","black")) l4 =
> list("sp.text", c(77500,65360), "0") l5 = list("sp.text",
> c(77750,65360), "250") l6 = list("sp.text", c(78000,65360),
> "500m") cuts = 199 at = c(0,10,20,30,40,50,60,70,80,90) 
> spplot(slope.grid, zcol = "band1", col.regions = rainbow(200,
> start= 3/15, end = 1), cuts = cuts, pretty = F, sp.layout =
> list(l1, l2, l3, l4, l5, l6), lty = 1, lwd = 0.1, scales =
> list(draw = TRUE),xlim = bbox(roeser.grid)[1,], ylim = 
> bbox(roeser.grid)[2,], main = "Slope Map with Sampling locations")
> 
> Somehow the colour key does not start with zero. Or better said,
> there is a part of the colour ramp which signalises values below
> zero. The summary statistics show that the minimum value is 0.00
> 3956468.
> 
> You can find a screenshot here: 
> http://ubuntuone.com/1b6DAeKvoMTlvFZumWuIXz Any suggestions what I
> am doing wrong?
> 
> Thanks very much, Ulrich 
> ______________________________________________
> 
> Ulrich Leopold
> 
> Senior Researcher in Geocomputation Resource Centre for
> Environmental Technologies Public Research Centre Henri Tudor 6A,
> avenue des Hauts-Fourneaux L-4362 Esch-sur-Alzette Luxembourg
> 
> tel: +352 425991 4618 fax: +352 425991 555 mobile: +352 691 304813 
> email: ulrich.leopold at tudor.lu http://www.tudor.lu
> 
> 
> 
> _______________________________________________ R-sig-Geo mailing
> list R-sig-Geo at r-project.org 
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

- -- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJR6BpAAAoJEM1OCHCtOnfxHkwH/2MYdpDHM7pNPu81pAdEgjUp
XsF64F8hCKPGA2DlFKOnthYhK10PVsdzfNZ1yISd04CqP/HyBAgwpiwWP+ie0Vji
GmslduK6Ab1YsjLZ1+PSkfSV8BESN9k6DOV4TrIpNNWtE4nubOCL+cm6xwu/aAnf
mCQo+kINq78AVs66eL+8LIoGQ7L1IGFHmR3fEMCvoCs727W8lgLJphvq2593zE05
ZnYQSJEwUFCpXWlOkbRK/lNz/KYdl35D31BWc/T728qpMLRfN0W4WlMjXUYfiQPw
vaUw+2rDPLl1RX6+4+CzBdeEiGYvufTaY24m1CRtSxc+KpmngB0ey0+iixm121c=
=mDoU
-----END PGP SIGNATURE-----



More information about the R-sig-Geo mailing list