使用rasterio和rioxarray完成此示例:
# Open zarr data in xarray
import xarray as xr
import s3fs
fs = s3fs.S3FileSystem(anon=True)
urls = ["s3://hrrrzarr/sfc/20210915/20210915_12z_fcst.zarr/surface/APCP_acc_fcst",
"s3://hrrrzarr/sfc/20210915/20210915_12z_fcst.zarr/surface/APCP_acc_fcst/surface"]
ds = xr.open_mfdataset([s3fs.S3Map(url, s3=fs) for url in urls], engine="zarr")
# Assign CRS projection using rioxarray
import rioxarray
from pyproj import CRS
ds = ds.rename(projection_x_coordinate="x", projection_y_coordinate="y")
crs = CRS.from_cf({"grid_mapping_name":"lambert_conformal_conic", "longitude_of_central_meridian":-97.5,
"latitude_of_projection_origin": 38.5,
"standard_parallel":38.5})
ds = ds.rio.write_crs(crs, inplace=True)
ds["APCP_acc_fcst"] = ds["APCP_acc_fcst"].astype("float64") # Original data uses short floats which cause an error
ds = ds.rio.reproject("EPSG:4326") # Arbitrarily picked a projection since GEE seems to want projections w/ official codes
# Save as GeoTiff
ds["APCP_acc_fcst"].rio.to_raster("example.tif")