Skip to content

Instantly share code, notes, and snippets.

@parevalo
Last active November 26, 2024 21:09
Show Gist options
  • Select an option

  • Save parevalo/a23f0fe98abde52f90cfaea337a806c0 to your computer and use it in GitHub Desktop.

Select an option

Save parevalo/a23f0fe98abde52f90cfaea337a806c0 to your computer and use it in GitHub Desktop.
@dask.delayed
def load_cog(url):
return rxr.open_rasterio(url,
chunks=({'x': 512, 'y': 512}),
lock=False,
mask_and_scale=True).squeeze('band', drop=True)
@dask.delayed
def load_scene(scene_links):
delayed_loads = [load_cog(url) for url in scene_links]
ds = xr.concat(dask.compute(*delayed_loads), dim="band")
ds.coords['band'] = BANDS
return ds
delayed_ds = [load_scene(scene_links) for scene_links in granule_links]
time_var = xr.Variable('time', time)
ts = xr.concat(dask.compute(*delayed_ds), dim=time_var)
ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment