Skip to content

Instantly share code, notes, and snippets.

@tastatham
Created May 5, 2022 08:28
Show Gist options
  • Save tastatham/7305dc8f8ea5dc51da3c227fa92ed9d4 to your computer and use it in GitHub Desktop.
Save tastatham/7305dc8f8ea5dc51da3c227fa92ed9d4 to your computer and use it in GitHub Desktop.
A list of functions for rioxarray
def list_tifs(path):
import glob
tifs = []
for p in glob.glob(f"{path}/*/**/*.tif", recursive=True):
t = p
if "_HS_" not in t:
tifs.append(t)
return tifs
def merge_tifs(tifs):
from rioxarray import open_rasterio, merge
elems = []
for val in tifs:
rds = open_rasterio(val)
elems.append(rds)
return merge.merge_arrays(elems)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment