[R] add single points to a level plot
chocold12 at gmail.com
Thu Mar 8 18:10:48 CET 2018
Now it can run and generate plots, but there are the two lines on each of
the plots. I don't know the problem for this?
Error using packet 1
any(sp) is not TRUE
On Thu, Mar 8, 2018 at 8:48 AM, Eric Berger <ericjberger at gmail.com> wrote:
> You need to load the package 'rasterVis'
> > library(rasterVis)
> On Thu, Mar 8, 2018 at 5:11 PM, lily li <chocold12 at gmail.com> wrote:
>> Hi all,
>> I ran the code:
>> > s <- stack(replicate(2, raster(matrix(runif(100), 10))))
>> > xy <- data.frame(coordinates(sampleRandom(s, 10, sp=TRUE)),
>> + z1=runif(10), z2=runif(10))
>> > levelplot(s, margin=FALSE, at=seq(0, 1, 0.05)) +
>> + layer(sp.points(xy, pch=ifelse(pts$z1 < 0.5, 2, 3), cex=2, col=1),
>> columns=1) +
>> + layer(sp.points(xy, pch=ifelse(pts$z2 < 0.5, 2, 3), cex=2, col=1),
>> And got the error:
>> Error in UseMethod("levelplot") :
>> no applicable method for 'levelplot' applied to an object of class
>> "c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"
>> what is the problem? Thanks.
>> On Thu, Mar 8, 2018 at 12:07 AM, lily li <chocold12 at gmail.com> wrote:
>> > Hi all,
>> > I'm trying to add single points with known coordinates to a level plot,
>> > but could not find the proper answer. I got to know that layer()
>> > is good for this, but I don't know which package is related to this
>> > function. The source is here:
>> > https://stackoverflow.com/questions/28597149/add-xy-points-
>> > generated-by-levelplot
>> > but my question is a little different as I know the coordinates of the
>> > single point, rather than a range. Thanks for any help you could
>> [[alternative HTML version deleted]]
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help