You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a strange behaviour when defining the srs in gdalcubes::cube_view as a WKT. I created a data cube, but used terra:crs() to set the srs from an existing spatRaster object. In the reproducible example below a similar way to set srs using the example from the package.
No problem so far. An error only occurs when using this data cube in a subsequent reduce_time() function, but only when using the FUN argument, and not the expr argument. In the example below two ways to create a median value composite. I have no clue what is causing this or whether it is machine dependent. When using the proj4 or EPSG notation both functions execute correctly.
#Median compositing function 1 - with expr
cube_composite.median <- function(cube){
names <- gdalcubes::bands(cube)$name
comp_args <- list(x=cube)
comp_args <- c(comp_args, lapply(names, function(x){paste0("median","(",x,")")}))
composite <- do.call(gdalcubes::reduce_time, comp_args)
return(composite)
}
#Median compositing function 2 - with FUN
cube_composite.median2 <- function(cube){
names <- gdalcubes::bands(cube)$name
composite <- gdalcubes::reduce_time(cube, names=names, FUN=function(x){
x_median <- apply(x, 1, median, na.rm=TRUE)
return(x_median)
})
return(composite)
}
#Apply the two median composite functions
L8.median <- cube_composite.median(L8.cube)
plot(L8.median, rgb=3:1)
L8.median2 <- cube_composite.median2(L8.cube)
plot(L8.median2, rgb=3:1)
The text was updated successfully, but these errors were encountered:
There seems to be a strange behaviour when defining the srs in
gdalcubes::cube_view
as a WKT. I created a data cube, but usedterra:crs()
to set the srs from an existing spatRaster object. In the reproducible example below a similar way to set srs using the example from the package.No problem so far. An error only occurs when using this data cube in a subsequent
reduce_time()
function, but only when using theFUN
argument, and not theexpr
argument. In the example below two ways to create a median value composite. I have no clue what is causing this or whether it is machine dependent. When using the proj4 or EPSG notation both functions execute correctly.The text was updated successfully, but these errors were encountered: