terrabyte
In this example, it is demonstrated how to retrieve Landsat satellite data for a specific week in May on terrabyte and process it to generate true-color images. The cloud coverage is limited to 0-20%.
Load CUDA libraries (only if CUDA lib error occures)¤
Python
import ctypes
import os
import glob
cuda_lib_dir = "/usr/local/cuda/lib64"
so_files = [f for f in glob.glob(os.path.join(cuda_lib_dir, "*.so")) if os.path.isfile(f)]
failed_libs = {lib: None for lib in so_files}
for attempt in range(4):
for lib_path in list(failed_libs.keys()):
try:
ctypes.CDLL(lib_path)
del failed_libs[lib_path]
except Exception as e:
failed_libs[lib_path] = str(e)
if attempt == 3: print(f"Failed to load {lib_path}: {str(e)}")
if not failed_libs:
print("\nAll libraries loaded successfully!")
break
Data Download¤
Python
from sipt.retrieval import TerraByte, copy
import os
shapefile = './shape.geojson'
start_date = '2024-05-10'
end_date = '2024-05-16'
TerraByte.retrieve("./data", TerraByte.Collection.LANDSAT_8_9_OT_C2_L2, shapefile, start_date, end_date)
copy("./data/sources.txt", "./src", shapefile, ["*_B[2345]*", "*SCL_20m*"],
start_date, end_date, num_processes=8)
Pre-Processing¤
Python
from sipt.pipeline import preprocess
from sipt.processing.mask import MaskType
# Bit Flag Description
# Fill (0), Dilated Cloud (1), Cirrus (2), Cloud (3), Cloud Shadow (4), Snow (5), Clear (6), Water (7)
preprocess("./src", "./processed", shapefile, "*SCL_20m*", MaskType.BITMASK, 0b00001110,
max_masked_area=20, num_processes=8)