shannonspragg / SOI-Grizz

The analysis code for Ch.1 of integrating social values for grizzly bears into the biophysical landscape of the Southern Interior
0 stars 0 forks source link

Avoid projecting rasters #7

Open mattwilliamson13 opened 2 years ago

mattwilliamson13 commented 2 years ago

At line 105. in script 1, this fixes and still leaves the object name you want:

  # Make our SOI template raster:
soi.vect <- vect(south.int.10k.buf)
soi.vect.p <- terra::project(soi.vect, crs(grizz.inc.rast))
grizzinc.crop.t <- terra::crop(grizz.inc.templ, soi.vect.p)  
mattwilliamson13 commented 2 years ago

Full code is

soi.vect <- vect(south.int.10k.buf)
soi.vect.p <- terra::project(soi.vect, crs(grizz.inc.rast))
grizzinc.crop.t <- terra::crop(grizz.inc.rast, soi.vect.p)  

#soi.rast.templ <- rast(soi.vect, nrows= 218, ncols=298, nlyrs=1, xmin=1149612, xmax=1585533, ymin=453864.2, ymax=772759.3)
soi.rast <- terra::rasterize(soi.vect.p, grizzinc.crop.t, field = "OBJECTID")
soi.rast <- resample( soi.rast, grizzinc.crop.t, method='bilinear')
soi.rast[soi.rast == 327] <- 0

Want to make sure that setting that to 0 isn't a problem.