- 生成 tiff 文件
from eccodes import * import numpy as np import xarray as xr import rioxarray as rio
t2 = xr.Dataset(data_vars={'REF': (['longitude', 'latitude'], DATA)}, coords={ 'longitude': (['longitude'], new_longrid[:, 0]), 'latitude': (['latitude'], new_latgrid[0]), }) print(t2) t2.rio.set_spatial_dims('latitude', 'longitude') t2.rio.set_crs("epsg:4326") t2.rio.to_raster(r"t2_raster.tiff")
- 可视化 tiff
import matplotlib.pyplot as plt from pylab import * import xarray as xr from matplotlib import rcParams dem = xr.open_rasterio('t2_raster.tiff') dem = dem[0] #getting the first band dem.plot(cmap='terrain') plt.show()
参考 :https://www.heywhale.com/mw/project/622b2d808a84f900178933ac
https://www.heywhale.com/mw/project/628507931f8f7f5e2b45b284
标签:xarray,tiff,t2,生成,rio,xr,import,latitude From: https://www.cnblogs.com/luochunxi/p/16627420.html