bcgov / climr

An R package for downscaling monthly climate data for North America
https://bcgov.github.io/climr/
14 stars 6 forks source link

Can't pass SpatRaster to `normal_input` #150

Open CeresBarros opened 6 months ago

CeresBarros commented 6 months ago

documentation for the normal argument of normal_input suggests that a SpatRaster with normal variable values can be supplied, but I'm encountering an error when trying to supply one. What am I doing wrong?

reprex, with @devl version

library(terra)

dbCon <- data_connect()

xyz <- structure(list(Long = c(-127.70521, -127.62279, -127.56235, -127.7162, 
                                 ## smaller example in BC
                                 -127.18585, -127.1254, -126.94957, -126.95507),
                        Lat = c(55.3557, 55.38847, 55.28537, 55.25721, 54.88135, 54.65636, 54.6913, 54.61025),
                        Elev = c(291L, 296L, 626L, 377L, 424L, 591L, 723L, 633L),
                        ID = LETTERS[1:8],
                        Zone = c(rep("CWH",3), rep("CDF",5)),
                        Subzone = c("vm1","vm2","vs1",rep("mm",3),"dk","dc")),
                   row.names = c(NA, -8L), class = "data.frame")

thebb <- get_bb(xyz)
normalout <- normal_input(dbCon, thebb, normal = list_normal()[1], cache = TRUE)

normalout2 <- normal_input(dbCon, thebb, normal = normalout[[1:36]], cache = TRUE)
kdaust commented 6 months ago

I don't think you're doing anything wrong, but I haven't implemented that yet in the new postgres version. On my todo list.

CeresBarros commented 4 months ago

@cmahony , @kdaust, is this really necessary for v1.0.0? perhaps for now we could simply fix the documentation?

cmahony commented 4 months ago

up to @kdaust as i'm not sure how involved this is. fine to leave to v2 if difficult.