#!/usr/bin/env python # coding: utf-8 # # Resample 1km grid to 25km grid # In[1]: import fsspec import rioxarray as rxr import hvplot.xarray # In[2]: fs_osn = fsspec.filesystem('s3', anon=True, client_kwargs={'endpoint_url': 'https://mghp.osn.xsede.org'}) # In[3]: fs_osn.ls('s3://rsignellbucket1/testing/ndvi/') # In[4]: public_url ='https://mghp.osn.xsede.org/rsignellbucket1/testing/ndvi/2018062.1_km_VIIRS_NDVI_cog.tif' # In[5]: da_1km = rxr.open_rasterio(public_url, masked=True).squeeze('band', drop=True) # In[6]: da_1km # In[7]: get_ipython().run_cell_magic('time', '', 'da_1km = da_1km.load()\n') # In[8]: da_1km.nbytes/1e9 # GB # In[9]: res = 25 # In[10]: get_ipython().run_cell_magic('time', '', "da_25km = da_1km.coarsen(x=res, y=res, boundary='pad').mean()\n") # In[11]: da_25km.spatial_ref.attrs # In[12]: da_25km.hvplot(x='x', y='y', rasterize=True, geo=True, tiles='OSM', cmap='turbo', clim=(-1000,8000))