Closed CyprienBosserelle closed 9 months ago
Thanks @CyprienBosserelle
It looks like I will want to do something like:
encode = {"data_source": {'zlib': True, 'complevel': 1, 'grid_mapping': dem.data_source.encoding['grid_mapping'], },
"lidar_source": {'zlib': True, 'complevel': 1, 'lidar_source': dem.lidar_source.encoding['grid_mapping'], },
"z": {'zlib': True, 'complevel': 1, 'z': dem.data_source.encoding['z'], },
"zo": {'zlib': True, 'complevel': 1, 'zo': dem.data_source.encoding['zo'], }}
dem.to_netcdf(filename, encoding=encode, format="NETCDF4", engine="netcdf4")
Note also need to ensure the spatial info is written into the compression as otherwise no spatial information is included. Updated example above
using a deflation on Netcdf files will reduce file size by hopefully a huge factor:
https://gis.stackexchange.com/questions/377299/adding-compression-to-a-netcdf-file-using-xarray