hunzikp / velox

https://hunzikp.github.io/velox/
119 stars 23 forks source link

Error when applying velox-functions on velox-stack #6

Closed georgeblck closed 6 years ago

georgeblck commented 7 years ago

Hello, thank you for this package; I am really impressed by the speed. Currently I am working with some big raster stacks and am obviously trying to get by with your fast methods.

Maybe I am doing something wrong, but often when I call your methods on velox-stacks, I get this error Error: attempt to apply non-function

I am trying to create a reproducible example, but the error is not easily isolated. What I have found for now is that this works

# create a velox object by explicitly stating the individual raster stack layers
velox.stack <- velox(raster.stack[[1]], raster.stack[[2]])
# apply some fast functions
velox.stack$aggregate
# velox-->raster stack again
new.raster.stack <- velox.stack$as.RasterStack()

while the following code does not work (for some of my files)

# create a velox object by just handing over the whole stack
velox.stack <- velox(raster.stack)
# apply some fast functions
velox.stack$aggregate
Error: attempt to apply non-function

For now I have only checked two functionsaggregate and rasterize, where both produce the error. When I can create a nice reproducible example for you, I will post it here.

Regarding my OS specs: I am working on Fedora23 with R-Version 3.3.1

hunzikp commented 6 years ago

Hi George,

Thanks for the comment. It's difficult to tell from your example, but I suspect you got the error because you passed RasterBrick objects (rather than RasterStack objects) to the velox function.

I addressed this problem in two ways: (1) velox can now cast from and to RasterBrick objects. (2) When you pass an unsupported object to the velox function it throws an error immediately (rather than returning a NULL object, which led to the error you encountered).

Cheers, ph