Guest User

Untitled

a guest
Jan 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. library(raster)
  2. library(rgdal)
  3.  
  4. # Load footprint from file into rasterBrick object
  5. path_to_footprint_nc <- './footprint.nc'
  6. footprint <- brick(path_to_footprint_nc)
  7.  
  8. # Sum values per-cell into raster object
  9. r_all <- sum(footprint)
  10.  
  11. # Read in counties shapefile
  12. shape <- readOGR(dsn = 'Counties', layer = 'Counties')
  13.  
  14. # Grab the SLCo polygon from the counties shapefile
  15. slco <- spTransform(subset(shape, NAME == 'SALT LAKE'), CRS('+proj=longlat'))
  16.  
  17. # Replace values outside of SLCo with NA
  18. r_slco <- mask(r, slco)
  19.  
  20. # Plot pre-crop and post-crop for validation
  21. op <- par(mfrow = c(1, 2))
  22. plot(r_all, main = 'Full Domain')
  23. plot(r_slco, main = 'SLCo')
  24. par(op)
Add Comment
Please, Sign In to add comment