<jupyter_start><jupyter_text>Mosaicking<jupyter_code>import os
from time import time
import xarray as xr
import rioxarray
import rasterio<jupyter_output><empty_output><jupyter_text>Function of mosaicking<jupyter_code>def xr_build_mosaic_ds(tifs, product='band'):
    start = time()
    my_da_list = []
    topleft_affine = None
    for i, tif in enumerate(tifs):
        da = xr.open_rasterio(tif)
        da = da.squeeze().drop(labels='band')
        da.name = product
        my_da_list.append(da)
        tnow = time()
        elapsed = tnow - start
        print(tif, elapsed)
    ds = xr.merge(my_da_list)
    return ds

def xr_write_geotiff_from_ds(ds, out_path):
    print(ds)
    print(f'OUTPUT=={out_path}')
    ds.rio.to_raster(out_path)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1093951093951094, 'fraction_numerical': 0.0, 'mean_word_length': 3.7151515151515153, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '490273', 'license': 'MIT', 'n_tokens_mistral': 306, 'n_tokens_neox': 299, 'n_words': 52, 'path': 'postprocess-avgs/other_fun_schitt/mosaicking.ipynb', 'repo_name': 'tonybutzer/enduser', 'size': '777'}