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

Error with sits_apply(), data cube needs to be reloaded #1222

Open
paulacopelli opened this issue Oct 8, 2024 · 2 comments
Open

Error with sits_apply(), data cube needs to be reloaded #1222

paulacopelli opened this issue Oct 8, 2024 · 2 comments
Labels

Comments

@paulacopelli
Copy link

Hello! When performing calculations on my data cube using sits_apply(), it allows me to run the first calculation, but then I encounter an "invalid input data" error, even though I'm using the same data cube that was processed previously.

My solution was to reload the data cube every time a calculation was performed and to save the index images in a separate folder from the data cube. Once I had all the indices of interest, I simply clipped the layers from the new folder and added them to the data cube folder.

@gilbertocamara
Copy link
Contributor

Dear @paulacopelli, many thanks for your message. Would it be possible to provide us a minimum working example (MWE). We have been using sits_apply() in many situations and this error has not been reported before. Many thanks for your interest in sits and compliments in your skills in finding workarounds bugs in the software.

@paulacopelli
Copy link
Author

paulacopelli commented Oct 17, 2024

Dear @gilbertocamara, thank you very much for your response. Here I have the code I am using for processing:

cube = 'D:/ruta/cube_itata_mosaic'
parse_info = c("satellite", "sensor", "tile", "band", "date")

# Carga del cubo --------------------------------------------------------
cube_itata_mosaic <- sits_cube(
  source     = "MPC",
  collection = "SENTINEL-2-L2A",
  data_dir   = cube,
  parse_info = parse_info
)

sits_timeline(cube_itata_mosaic)

sits_bands(cube_itata_mosaic)

# 2. Calculo de índices --------------------------------------------------------

# Calculate NDVI index using bands B08 and B04
cube_itata_mosaic <- sits_apply(
  data        = cube_itata_mosaic,
  NDVI        = (B08 - B04) / (B08 + B04),
  output_dir  = cube,
  memsize     = 6,
  multicores  = 4,
  progress    = TRUE
)

# Calculate EVI index using bands B08 and B04
cube_itata_mosaic <- sits_apply(
  data        = cube_itata_mosaic,
  EVI         = 2.5 * (((B08 - B04) / (B08 + (6 * B04) - (7.5 * B02) + 1))),
  output_dir  = cube,
  memsize     = 6,
  multicores  = 4,
  progress    = TRUE
)

When I apply the second index, it tells me the following message:
Error: sits_apply: invalid input data and/or function to be applied

I noticed that the error may be linked to an error in the processing of the indices, because for some reason neither the pixel resolutions nor the size (number of pixels in the width and length) of the resulting raster of the base bands match with the indexes. When I calculate the indices through another tool, it is able to load the complete cube correctly and continue processing it, for example, to extract data.

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

No branches or pull requests

2 participants