SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(raster)
  2. library(sp)
  3.  
  4. r <- raster(xmn=1, xmx=5, ymn=1, ymx=5, nrows=4, ncols=4)
  5. r[] <- 1:length(r)
  6.  
  7. Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
  8. Sr2 = Polygon(cbind(c(4.1,4,2),c(2,3,2)))
  9.  
  10. SpP = SpatialPolygons(list(Polygons(list(Sr1), "s1"), Polygons(list(Sr2), "s2")), 1:2)
  11.  
  12. plot(mask(r, SpP))
  13. plot(SpP,  add=TRUE)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top