HLS V2.0 data format
Posted: Mon Jun 12, 2023 4:59 am America/New_York
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)
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)