brazil-data-cube / rstac

R Client Library for SpatioTemporal Asset Catalog
https://brazil-data-cube.github.io/rstac
Other
70 stars 15 forks source link

Error when querying STAC with sits package tracedback to rstac #126

Closed daniel-althoff closed 1 year ago

daniel-althoff commented 1 year ago

Hi, I use the sits package frequently and I noticed that it was working two days ago, and when I updated my packages it stop working when using the sits::sits_cube() function. It seems like the latest version of rstac might have created a conflict. I'm not completely sure though.

edit: I reverted to rstac 0.9.1_5 and it worked fine.

Just use any given roi, e.g.,

roi_sf = geobr::read_state('SC')
sits_cube(
  source = "AWS", 
  collection = "SENTINEL-S2-L2A-COGS", 
  roi = roi_sf %>% st_transform(crs = "wgs84"), 
  bands = c("B04",  "B08",  "CLOUD"), 
  start_date = as.Date("2022-09-15"), 
  end_date = as.Date("2022-10-15"), 
  progress = T)

Returns the following:

Error: lexical error: invalid char in json text. search_phase_execution_exceptio (right here) ------^

Traceback:

  1. sits_cube(source = "AWS", collection = "SENTINEL-S2-L2A-COGS", . roi = roi_sf %>% st_transform(crs = "wgs84"), bands = c("B04", . "B08", "CLOUD"), start_date = as.Date("2022-09-15"), . end_date = as.Date("2022-10-15"), progress = T)
  2. sits_cube.stac_cube(source = "AWS", collection = "SENTINEL-S2-L2A-COGS", . roi = roi_sf %>% st_transform(crs = "wgs84"), bands = c("B04", . "B08", "CLOUD"), start_date = as.Date("2022-09-15"), . end_date = as.Date("2022-10-15"), progress = T)
  3. .source_cube(source = source, collection = collection, bands = bands, . tiles = tiles, roi = roi, start_date = start_date, end_date = end_date, . platform = platform, progress = progress, ...)
  4. .source_cube.stac_cube(source = source, collection = collection, . bands = bands, tiles = tiles, roi = roi, start_date = start_date, . end_date = end_date, platform = platform, progress = progress, . ...)
  5. .source_items_new(source = source, collection = collection, stac_query = items_query, . tiles = tiles, platform = platform, ...)
  6. .source_items_new.aws_cube(source = source, collection = collection, . stac_query = items_query, tiles = tiles, platform = platform, . ...)
  7. rstac::items_fetch(items = items_info, progress = progress)
  8. items_fetch.STACItemCollection(items = items_info, progress = progress)
  9. tryCatch({ . items_next(items, ...) . }, next_error = function(e) NULL)
  10. tryCatchList(expr, classes, parentenv, handlers)
  11. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  12. doTryCatch(return(expr), name, parentenv, handler)
  13. items_next(items, ...)
  14. items_next.STACItemCollection(items, ...)
  15. post_request(next_stac, ..., encode = q$encode)
  16. after_response(q, res = res)
  17. after_response.search(q, res = res)
  18. after_response.items(q, res)
  19. content_response(res, status_codes = "200", content_types = c("application/geo+json", . "application/json"))
  20. httr::content(res, type = content_type, encoding = "UTF-8", simplifyVector = TRUE, . simplifyDataFrame = FALSE, simplifyMatrix = FALSE)
  21. parse_auto(raw, type, encoding, ...)
  22. parser(x = content, type = type, encoding = encoding, ...)
  23. jsonlite::fromJSON(parse_text(x, encoding = "UTF-8"), simplifyVector = simplifyVector, . ...)
  24. parse_and_simplify(txt = txt, simplifyVector = simplifyVector, . simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, . flatten = flatten, ...)
  25. parseJSON(txt, bigint_as_char)
  26. parse_string(txt, bigint_as_char)
OldLipe commented 1 year ago

Hi @daniel-althoff,

Thanks for reporting. Indeed, there was a bug in rstac search function.

We fixed it. You can install using devtools::install_github("brazil-data-cube/rstac").

We will resubmit to CRAN this hotfix as soon as possible.