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

Issue with cores argument when using lapp() on a SpatRasterDataset #1190

Closed
kel44 opened this issue Jun 16, 2023 · 2 comments
Closed

Issue with cores argument when using lapp() on a SpatRasterDataset #1190

kel44 opened this issue Jun 16, 2023 · 2 comments

Comments

@kel44
Copy link

kel44 commented Jun 16, 2023

I am trying to apply a custom function to two spatial rasters (about 10,000 layers each) that make up a spatial dataset. This works fine when I leave the cores argument as the default 1 (though it takes a long time to run) but when I try to up the number of cores >1, I get an error "Error in (function (r1, r2) : unused argument (cores = 2). When I use the cores argument with the app() function (using a dummy test function) on the same spatial dataset, everything works peachy.

In search of a solution, I was looking at the code for the app and lapp functions. I noticed this difference which I suspect might be leading to my issue.

In app();

setMethod("app", signature(x="SpatRasterDataset"),
function(x, fun, ..., cores=1, filename="", overwrite=FALSE, wopt=list())

Versus in lapp() ;

setMethod("lapp", signature(x="SpatRasterDataset"),
function(x, fun, ..., usenames=FALSE, recycle=FALSE, filename="", overwrite=FALSE, wopt=list())

I am just wondering if there is a reason for the lack of built in parallel processing with lapp() on spatial data sets, or if it was simply an oversight. Thank you so much for your work writing and maintaining this resource for all.

@kel44 kel44 changed the title Issue with cores argument when using lapp() on a Spatial Data Set Issue with cores argument when using lapp() on a SpatRasterDataset Jun 16, 2023
@rhijmans
Copy link
Member

This is not an "issue" in the sense of the software not doing what it was designed to do. The feature is simply not available (and that is not an oversight). You are requesting a new feature (and that is fine).

@rhijmans
Copy link
Member

At long last, lapp<SpatRasterDataset> now also has argument "cores"

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Feb 15, 2025
# version 1.8-21

## bug fixes

- `sieve` failed with large rasters
  [#1729](rspatial/terra#1729) by Reed
  Humphrey

- `extractRange` only worked for SpatVector, not for matrix or vector
  [#1733](rspatial/terra#1733) by Victor Van
  der Meersch

- `extract<SpatRaster>` over https with a multilayer SpatRaster
  returned the values for the first layer for all layer
  [#1736](rspatial/terra#1736) by Shannon
  Albeke

## enhancements

- new argument xyz="" to the `rast<SpatVector>` method

- new arguments "type" and "breaks" to `plet<SpatRaster>` method
  [#1187](rspatial/terra#1187) by Augustin
  Lobo

- new argument "cores" in `lapp<SpatRasterDataset>`
  [#1190](rspatial/terra#1190) by kel44

- `aggregate<SpatRaster>` now handles `fun="table"`
  [#1662](rspatial/terra#1662) by Fernando
  Aramburu.

## new

- `is.flipped<SpatRaster>` method
  [#1627](https://github.com/rspatial/terra/issues/1627)>` by Timothée
  Giraud

- `as.array<SpatRasterDataset>` method

- `distance<SpatRaster,missing>` now has argument "values". If TRUE,
  the values of the nearest non-target cell is returned instead of the
  distance [#1243](https://github.com/rspatial/terra/is sues/1243) by
  Simon Dedman

- `thresh<SpatRaster>`
  [#1233](rspatial/terra#1233) by Agustin
  Lobo
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

2 participants