-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi!
I've been trying to run the model for my study area but I keep getting an error and cannot figure out what I've been doing wrong. I was hoping you could help me, please?
I have a habitat raster for the area which I input into get_dem(), then that goes into runauto() along with the habitat raster. It runs until "Calculating wind shelter coefficients", then gives me the error:
"Error in if (class(sel) == "logical") { : the condition has length > 1"
I get the same error if I do not use get_dem() beforehand, and input my habitat raster as r. The function runs without any errors if I provide lat/lon coordinates into get_dem() and use that, so I'm assuming the issue is with the habitat raster? Below is the info on the habitat and dem rasters, and the code I'm using. Thank you!
hab
class : SpatRaster
dimensions : 158, 101, 1 (nrow, ncol, nlyr)
resolution : 124.6796, 124.6796 (x, y)
extent : -897105.9, -884513.2, 4497324, 4517024 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / World Mercator (EPSG:3395)
source(s) : memory
name : Value
min value : 2
max value : 14
r
class : SpatRaster
dimensions : 158, 101, 1 (nrow, ncol, nlyr)
resolution : 124.6796, 124.6796 (x, y)
extent : -897105.9, -884513.2, 4497324, 4517024 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / World Mercator (EPSG:3395)
source(s) : memory
name : file4ea428861feb
min value : 136.3815
max value : 277.0664
library(terra)
library(NicheMapR)
library(microclima)
hab[hab == 0] <- NA
hab <- terra::project(hab, "EPSG:3395", method = "near")
r <- get_dem(hab, resolution = 30)
r <- resample(r, hab, method = "bilinear")
stday <- "01/07/2009"
endday <- "02/07/2009"
temps <- runauto(r = r, dstart = stday, dfinish = endday, hgt = 0.20, l = NA,
x = NA, habitat = hab, hourlydata = NA, dailyprecip = NA,
use.raster = FALSE, r.is.dem = TRUE, coastal = FALSE,
plot.progress = FALSE, save.memory = TRUE, summarydata = FALSE,
run.gads = 2)