[R-sig-Geo] cutting in spplot
Maxime Pauwels
Maxime.Pauwels at univ-lille1.fr
Fri Dec 19 12:07:17 CET 2008
Dear all,
I have a little problem using sppplot that may be easy to resolve for
some of you.
I work with a data frame called "rthrshldrange.txt" including 3
variables: thrshldrange.lat, thrshldrange.long and an attribute, "gridr"
rrange=read.table("rthrshldrange.txt", header=T)
head(rrange)
# thrshldrange.lat thrshldrange.long gridr
#1 54.66292 22.463592 -0.38001696
#2 44.55056 6.888350 0.38050517
#3 45.22472 15.262136 -0.01351420
#4 54.49438 8.898058 0.06822382
#5 48.76404 17.104369 -0.29690619
#6 54.83146 21.123786 -0.39500770
range(rrange$gridr)
#[1] -0.4009798 0.3823646/
After reading, the data.frame is gridded to be able to draw items
afterwards using sp.layout
coordinates(rrange)=~thrshldrange.long+thrshldrange.lat
gridded(rrange)=TRUE
#Warning messages:
#1: In points2grid(points, tolerance, round, fuzz.tol) :
# grid has empty column/rows in dimension 1
#2: In points2grid(points, tolerance, round, fuzz.tol) :
# grid has empty column/rows in dimension 2
Warning messages are not, I guess, a real problem.
spplot function works pretty well when I use a numerical value for the
argument cuts, e.g. cuts=100
spplot(rrange, scales=list(draw=T), xlim=c(-5, 30), ylim=c(40, 60),
xlab = "longitude (dec.)", ylab="latitude(dec.)",cuts=100,
col.regions=grey(1:200/200))
However, I'd like to impose the range of cutting (e.g. from -1 to 1) to
have the same range in different plots using different data with
different ranges for the gridr variable.
I tried:
spplot(rrange, scales=list(draw=T), xlim=c(-5, 30), ylim=c(40, 60),
xlab = "longitude (dec.)", ylab="latitude(dec.)",cuts=c(-1, -0.5, 0,
0.5, 1), col.regions=grey(1:200/200))/
and had the following error message:
Erreur dans cut.default(x, at, include.lowest = TRUE, labels = FALSE) :
nombre d'intervalles incorrect
De plus : Warning messages:
1: In if (length.out == 0) integer(0) else if (One) 1:length.out else if
(missing(by)) { :
la condition a une longueur > 1 et seul le premier élément est utilisé
2: In if (length.out > 2) if (from == to) rep.int(from, length.out) else
as.vector(c(from, :
la condition a une longueur > 1 et seul le premier élément est utilisé
3: In 1:length.out :
l'expression numérique a 5 éléments : seul le premier est utilisé/
What I understand is that my solution clearly doesn't work... But I have
no alternative yet...
Could anyone help?
Many thanks and Merry Xmas
Best regards,
max
--
Maxime Pauwels
Post-Doc
Laboratoire de Génétique et Evolution des Populations Végétales
UMR CNRS 8016
Batiment SN2 Tel : +33 3 20 43 40 76
Universite de LILLE 1 Fax : +33 3 20 43 69 79
59655 Villeneuve d'Ascq Cedex email: maxime.pauwels at univ-lille1.fr
FRANCE http://www.univ-lille1.fr/gepv
«Impose ta chance, serre ton bonheur et va vers ton risque. A te
regarder, ils s’habitueront.»
René Char
More information about the R-sig-Geo
mailing list