I have downloaded a land surface temperature (LST) raster from ECOSTRESS as well as it's associate cloud mask (you can sign-up for free here and download your own data).
NASA's tutorial (minute 31:15) on YouTube uses Python
to remove cloudy pixels from the LST image. I'd like to work with R
for the same task. So, I did:
library(terra)
# working dir
setwd <- "path/"
# read the raw LST
lst_raw <- rast(paste0(wd, "ECO2LSTE.001_SDS_LST_doy2022152172444_aid0001.tif"))
# read the cloud mask
cloud_mask <- rast(paste0(wd, "ECO2CLD.001_SDS_CloudMask_doy2022152172444_aid0001.tif"))
# convert the cloud mask to binary rast
cloud_mask_binary <- ?????????
The part of converting the cloud mask to binary raster in Python
is:
cloud.data = (cloud.data >> 2) & 1
I quote from the YouTube video:
To process this quality flag image into a cloud mask we are going to access the data array of this dataset with .data and we are going to bit shift this array two bits to the right and then and with one and this will produce a binary cloud mask.
What is the equivalent Python
's code for converting the cloud mask to binary raster in R
?
R 4.4.0, RStudio 2024.04.2 Build 764, Windows 11.