Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRS error in extract() with readchl functions #130

Open
KimBaldry opened this issue Feb 4, 2023 · 1 comment
Open

CRS error in extract() with readchl functions #130

KimBaldry opened this issue Feb 4, 2023 · 1 comment

Comments

@KimBaldry
Copy link
Contributor

KimBaldry commented Feb 4, 2023

Error when using

read_oc_sochla
readchla
readcha_mean

Error in spTransform(y1, projection(dummy)) :
second argument needs to be of class CRS

error origin is .big.extract

Will try to find a fix today.

@KimBaldry
Copy link
Contributor Author

Have written the below function to work with extract - only pulls MODISA daily files. This will do for now. @mdsumner would be good for you to check the function. Based off readCHL_month but had to add a couple of lines to make it work with extract().


readCHL_daily <- function(date,time.resolution = "daily", xylim = NULL, ..., inputfiles = NULL, latest = TRUE,lon180 = FALSE,
nobsonly = FALSE,
returnfiles = FALSE) {
if (is.null(inputfiles)) {
## memoize this call
files <- ocfiles("daily", product = "MODISA", varnam = "CHL", type = "L3m")
} else {
files <- inputfiles
}
if (returnfiles)
return(files)
if (missing(date)) {
if (latest) date <- max(files$date) else date <- min(files$date)
}
date <- raadtools:::timedateFrom(date)
files <- .processFiles(date, files, "daily")
rl <- lapply(files$fullname, raster::raster, varname = "chlor_a")
if (!is.null(xylim)) rl <- lapply(rl, raster::crop, raster::extent(xylim))
raster::setZ(raster::brick(rl), date)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant