Guest User

Untitled

a guest
Jan 7th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. library(raster)
  2. library(spatstat)
  3.  
  4. # First set the geographic extent we'll be using
  5. e <- extent(-20, 60, -40, 35)
  6.  
  7. # Then read in the Maximum Green Vegetation Fraction tiff and crop it
  8. mgvf <- raster("MGVF_2001_30_arc_sec.tif")
  9. mgvf.2001.africa <- crop(mgvf, e)
  10.  
  11. # Now let's create a window for in spatstat
  12. SP.win <- as(e, "SpatialPolygons")
  13. W <- as(SP.win, "owin")
  14.  
  15. # Finally, we create the .im object
  16. mgvf.img <- as.im(X = "mgvf.2001.africa", W = W)
  17.  
  18. # Notice, there are no errors thrown. However, compare the plots below and see the loss of information:
  19. plot(mgvf.2001.africa)
  20. plot(mgvf.img)
  21.  
  22. library(geostatsp)
  23. mgvf.img <- as.im(mgvf.2001.africa)
  24.  
  25. rotate = function(mat) t(mat[nrow(mat):1,,drop=FALSE]) # mat - matrix
Add Comment
Please, Sign In to add comment