Page 1 of 1

HLS V2.0 data format

Posted: Mon Jun 12, 2023 4:59 am America/New_York
by jasper.vandoninck
Hi,

I am using R with the "terra" and "rstac" to query and process images from LPCLOUD HLS collection. I noticed that the pixel values in the images I accessed can have different data types, some being integers (scaled between 0 and 10000) and some being floats (scaled between 0 and 1). Below is a reproducible example for two HLS.S30 tiles, but I have the same issue with HLS.L30. I don't know if this is because of the data themselves or because somehow the "terra" package does not apply a scalar for one but does for the other.
Any help on how to resolve this issue is appreciated. Apologies if this has been answered elsewhere.


## Reproducable example:
library(rstac)
library(terra)

endpoint <- "https://cmr.earthdata.nasa.gov/stac/LPCLOUD"

setGDALconfig("GDAL_HTTP_UNSAFESSL", value = "YES")
setGDALconfig("GDAL_HTTP_COOKIEFILE", value = ".rcookies")
setGDALconfig("GDAL_HTTP_COOKIEJAR", value = ".rcookies")
setGDALconfig("GDAL_DISABLE_READDIR_ON_OPEN", value = "EMPTY_DIR")
setGDALconfig("CPL_VSIL_CURL_ALLOWED_EXTENSIONS", value = "TIF")

items <- stac(endpoint) %>%
stac_search(ids=c("HLS.S30.T32ULC.2022237T103641.v2.0", "HLS.S30.T31UGT.2022237T103641.v2.0")) %>%
post_request()

item1 <- rast(items$features[[1]]$assets$B08$href)
item2 <- rast(items$features[[2]]$assets$B08$href)

item1
item2
item1[1]
item2[1]
is.int(item1)
is.int(item2)

Re: HLS V2.0 data format

Posted: Tue Jun 13, 2023 11:36 am America/New_York
by LP DAAC-EDL - dgolon
Hello @jasper.vandoninck Our developers are taking a look into this. We'll post more once we have an answer. Thanks!

Re: HLS V2.0 data format

Posted: Fri Jun 30, 2023 9:41 am America/New_York
by LP DAAC-EDL - dgolon
Hi @jasper.vandoninck Some of the HLS granules store the granule attributes differently. This is why data is being scaled for some granules and not for others. We will update the R tutorial in an upcoming sprint, but for now you can disable the auto scaling while reading the data and apply that manually for all your granules as a workaround.

We are aware of this issue and we are working with HLS team to list it under data products known issues. Thanks!