[R] How to add box layer using levelplot in R?

Jonsson amen.alyaari at Bordeaux.inra.fr
Fri Feb 21 22:06:18 CET 2014

I would like to add some boxes with special extent to my plot.


     gh <- raster()
     gh[] <- 1:ncell(gh)
     SP <- spsample(Spatial(bbox=bbox(gh)), 10, type="random")
Then plot them

  levelplot(gh, col.regions = rev(terrain.colors(255)), cuts=254,
margin=FALSE) +
  layer(sp.points(SP, col = "red"))
this plots a map with several crosses in it but I need to plot a box with
spacial extent:

     extent(gh) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90))
      e6 <- extent( 2  , 8 , 45   , 51  )

I wan to add e6 to the plot and put the number2 inside the box.Any hint

View this message in context: http://r.789695.n4.nabble.com/How-to-add-box-layer-using-levelplot-in-R-tp4685658.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list