[R] add single points to a level plot
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Thu Mar 8 16:53:22 CET 2018
library(sos)
findFn( "layer" )
findFn( "levelplot" )
Also, experts in spatial analysis tend to answer questions on the special mailing list where the Posting Guide says they should. Read it to find out where that is.
--
Sent from my phone. Please excuse my brevity.
On March 8, 2018 7:11:34 AM PST, 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),
>columns=2)
>
>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()
>function
>> 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-to-raster-map-
>> 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
>provide.
>>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list