[R-sig-Geo] spplot question

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Sep 28 21:27:37 CEST 2010


Eric, forgive me my rudeness to answer a private email to the list, but
for some reason I cannot find the original on the list, and also not in
its archives -- are you sure it arrived at r-sig-geo?

The question was why

spplot(lzm.krige.dir["var1.pred"], scales=list(draw=TRUE),
xlab="Easting",ylab="Northing",
cuts=seq(0.0,0.4,by=0.01),key.space="right",cex=1.1,col.regions=terrain.colors(41),

  main="Specific Yield Layer 1",sp.layout=list(pts))

results in two warnings and a useless plot.

The answer is that the spplot documentation is wrong. cuts is directly
passed to levelplot, and the documentation there states that it can only
contain the number of cuts, not more.

(this is not the case when using spplot on a SpatialPointsDataFrame
object, as in that case it is processed by the sp code.)

You can control the values where color changes with the "at" element of
a list passed to the colorkey argument, see ?levelplot after loading
library lattice.

Thanks for notifying, best regards,


On 09/28/2010 06:07 PM, Eric Morway wrote:
>  Hello Edzer,
> 
> I've written you in the past with an spplot question (found below or at
> http://r.789695.n4.nabble.com/sppolot-fill-below-minimum-legend-value-td902841.html#a902841). 
> I've recently posted a related question
> (http://r.789695.n4.nabble.com/spplot-cuts-td2716237.html#a2716237) but
> noticed today that it doesn't seem to be generating much interest.  I
> was hoping you might be able to consider the post.  Why does the spplot
> function call generate warnings and plot with a solid color when
> cuts=seq(0.0,0.4,by=0.01) instead of cuts=25?
> 
> Very Humbly,
> Eric Morway
> 
> On 9/11/2009 1:52 PM, Edzer Pebesma wrote:
>> Ah, I see. Then, if you include the 0.1 in the legend, you will not like
>> that the range 0.1-10 will cover the same legend space as 10-1000, on
>> the log-scale. To avoid this, renumber the<10 values e.g. to 9, and
>> label the 9 as 0.1 -- meaning that labels can not equal
>> as.character(cuts) anymore.
>> -- 
>> Edzer
>>
>> Roger Bivand wrote:
>>> On Fri, 11 Sep 2009, Eric Morway wrote:
>>>
>>>> Edzer,
>>>>
>>>> I apologize for the confusion.  Is there an option in spplot that
>>>> fills in blank/white cells (I'm assuming they are blank because they
>>>> have a value less than the minimum cut) with the minimum color on the
>>>> legend bar (in this case green)?  About a quarter of the way in from
>>>> the left edge of the image you'll notice a "hole" in the plot due to
>>>> these cells having values less than 10.  I would like to fill these
>>>> cells in without altering the legend, if possible.
>>> No, please see the help page for levelplot() in lattice, the at=
>>> argument is describes as follows:
>>>
>>>        at: numeric vector giving breakpoints along the range of 'z'.
>>>            Contours (if any) will be drawn at these heights, and the
>>>            regions in between would be colored using 'col.regions'.  In
>>>            the latter case, values outside the range of 'at' will not be
>>>            drawn at all.  This serves as a way to limit the range of the
>>>            data shown, similar to what a 'zlim' argument might have been
>>>            used for.  However, this also means that when supplying 'at'
>>>            explicitly, one has to be careful to include values outside
>>>            the range of 'z' to ensure that all the data are shown.
>>>
>>> So you'll need to adjust your at= to accommodate all of the data.
>>>
>>> Roger
>>>
>>>
>>>> Thanks, Eric
>>>>
>>>> Edzer Pebesma wrote:
>>>>> Eric, I've been reading your email over and over, but cannot
>>>>> understand
>>>>> what you want. I also could not find a question, despite your subject.
>>>>> -- 
>>>>> Edzer
>>>>>
>>>>> Eric Morway wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I've been working on an image created with spplot and with help have
>>>>>> gotten it very close to the final product.  One final modification I
>>>>>> would like to make involves filling in grid cells with values less
>>>>>> than the minimum value on the legend with the color corresponding to
>>>>>> the bottom of the legend.  In the attached figure, the minimum legend
>>>>>> value is 10, but there a few spots with values as low as 0.01. These
>>>>>> cells are currently blank/white.  I would like to avoid including
>>>>>> this
>>>>>> value on my legend due to the color spread on the plot becoming
>>>>>> homologous, that is, I would like the color spread to be maximized
>>>>>> between 10-1000.  Were I to go from 0.01-1000, the range I'm most
>>>>>> interested in (10-1000) would be confined to a more narrow range of
>>>>>> the legend.  I have played around with trying to specify a different
>>>>>> number of cuts for the legend vs plot area, but this causes a
>>>>>> disconnect between the legend and the colors displayed for the
>>>>>> different grid cells.  The spplot line looks like this (image
>>>>>> attached):
>>>>>>
>>>>>> pts<-list("sp.points",K.dat,pch=3,col="black",labels=as.character(K.dat$Kh))
>>>>>>
>>>>>>
>>>>>>
>>>>>> cuts<-c(10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000)
>>>>>>
>>>>>>
>>>>>>
>>>>>> spplot(lzm.krige.dir["var1.pred"],at=cuts,colorkey=list(at=log10(cuts),labels=as.character(cuts)),scales=list(draw=TRUE),
>>>>>>
>>>>>>
>>>>>>  
>>>>>> xlab="Easting",ylab="Northing",key.space="right",cex=1.1,col.regions=terrain.colors(22),main="Hydraulic
>>>>>>
>>>>>>
>>>>>> Conductivity of Layer 2",sp.layout=list(pts))
>>>>>>
>>>>>> Respectfully,
>>>>>> Eric Morway
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> R-sig-Geo mailing list
>>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>>>
>>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at stat.math.ethz.ch
>>>> 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
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list