我正在尝试读取这个 netcdf 文件并将其转换为 tif 文件并使用 xarray 读取它
import xarray as xr
import geemap
import numpy as np
from mayavi import mlab
# Step 1: Download the NetCDF file
url = 'https://github.com/giswqs/leafmap/raw/master/examples/data/wind_global.nc'
filename = 'wind_global.nc'
data = geemap.read_netcdf(filename)
# Step 2: Convert the NetCDF file to a GeoTIFF
tif = 'wind_global.tif'
geemap.netcdf_to_tif(filename, tif, variables=['u_wind', 'v_wind'], shift_lon=True)
print(data)
# Step 3: Read the GeoTIFF file using rioxarray
data = xr.open_rasterio(tif)
# Extract latitude and longitude values from the data
latitude = data.y.values
longitude = data.x.values
# Convert wind data from U/V components to magnitude and direction
u_wind = data.values[0]
v_wind = data.values[1]
wind_magnitude = np.sqrt(u_wind*2 + v_wind*2)
wind_direction = np.degrees(np.arctan2(u_wind, v_wind))
# Create a meshgrid of latitude and longitude
lon_grid, lat_grid = np.meshgrid(longitude, latitude)
这引发了我的错误 模块“xarray”没有属性“open_rasterio”
我需要这个文件:
https://github.com/giswqs/leafmap/raw/master/examples/data/wind_global.nc.
我已经使用过这个但丢失了文件。如果有请提供给我