Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. cld<- raster("cdl_30m_r_il_2014_albers.tif") #this is the large raster
  2. r<- stack(paste(path,"/data_robin/", fl,sep="")) #1 stack,I have 4000 similar
  3. mat<-as.data.frame(getValues(r)) # getting values from the stack
  4. xy<-xyFromCell(r,c(1:ncell(r)),spatial = TRUE)
  5. clip1 <- crop(cld, extent(r)) # Tried to crop it to a smaller size
  6. cells<-cellFromXY(clip1,xy)
  7. mat$landuse<- NA
  8. # mat$landuse<-cld[cells]
  9. mat$landuse<- extract(clip1,cells) #this line takes 5 mins based on profiling
  10.  
  11. > cld
  12. class : RasterLayer
  13. dimensions : 20862, 11758, 245295396 (nrow, ncol, ncell)
  14. resolution : 30, 30 (x, y)
  15. extent : 378585, 731325, 1569045, 2194905 (xmin, xmax, ymin, ymax)
  16. coord. ref. : +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0
  17. data source : /Users/kaswani/R/Image/cdl_30m_r_il_2014_albers.tif
  18. names : cdl_30m_r_il_2014_albers
  19. values : 0, 255 (min, max)
  20.  
  21. > r
  22. class : RasterStack
  23. dimensions : 9230, 7502, 69243460, 4 (nrow, ncol, ncell, nlayers)
  24. resolution : 0.7995722, 0.7995722 (x, y)
  25. extent : 589084.4, 595082.8, 1564504, 1571884 (xmin, xmax, ymin, ymax)
  26. coord. ref. : +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
  27. names : m_3608906_ne_16.1, m_3608906_ne_16.2, m_3608906_ne_16.3, m_3608906_ne_16.4
  28. min values : 0, 0, 0, 0
  29. max values : 255, 255, 255, 255
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement