Guest User

Untitled

a guest
Sep 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. f_mosaic = 't1.nc'
  2.  
  3. meta = {'width': dat_f.shape[1],
  4. 'height': dat_f.shape[2],
  5. 'crs': rasterio.crs.CRS(init='epsg:'+fi['CPER']['Reflectance']['Metadata']['Coordinate_System']['EPSG Code'].value.decode("utf-8")),
  6. 'transform': aff_final,
  7. 'count': dat_f.shape[0]}
  8.  
  9. with netCDF4.Dataset(f_mosaic, mode='w', format="NETCDF4") as t1:
  10. # Create spatial dimensions
  11. y = t1.createDimension('y', meta['width'])
  12. x = t1.createDimension('x', meta['height'])
  13. wl_dim = t1.createDimension('wl',meta['count'])
  14. reflectance = t1.createVariable("reflectance","int16",("wl","y","x",),fill_value=null_val,zlib=True)
  15. reflectance.setncattr('grid_mapping', 'crs')
  16. crs = t1.createVariable('crs', 'c')
  17. crs.spatial_ref = meta['crs'].wkt
  18. crs.epsg_code = meta['crs'].to_string()
  19. crs.GeoTransform = " ".join(str(x) for x in meta['transform'].to_gdal())
  20.  
  21. dat_f.to_netcdf(path=f_mosaic,mode='a',format='NETCDF4',encoding={'reflectance':{'zlib':True}})
Add Comment
Please, Sign In to add comment