wxee.image.Image.to_xarray
- Image.to_xarray(path: str | None = None, region: Geometry | None = None, scale: int | None = None, crs: str = 'EPSG:4326', masked: bool = True, nodata: int = -32768, progress: bool = True, max_attempts: int = 10) Dataset [source]
Convert an image to an xarray.Dataset. The
system:time_start
property of the image is used to set the time dimension, and each image variable is loaded as a separate array in the dataset.- Parameters:
region (ee.Geometry, optional) – The region to download the image within. If none is provided, the
geometry
of the image will be used.scale (int, optional) – The scale to download the array at in the CRS units. If none is provided, the
projection.nominalScale
of the image will be used.crs (str, default "EPSG:4326") – The coordinate reference system to download the array in.
masked (bool, default True) – If true, nodata pixels in the array will be masked by replacing them with numpy.nan. This will silently cast integer datatypes to float.
nodata (int, default -32,768) – The value to set as nodata in the array. Any masked pixels will be filled with this value.
progress (bool, default True) – If true, a progress bar will be displayed to track download progress.
max_attempts (int, default 10) – Download requests to Earth Engine may intermittently fail. Failed attempts will be retried up to max_attempts. Must be between 1 and 99.
- Returns:
A dataset containing the image with variables set.
- Return type:
xarray.Dataset
- Raises:
DownloadError – Raised if the image cannot be successfully downloaded after the maximum number of attempts.
Examples
>>> col = ee.ImageCollection("IDAHO_EPSCOR/GRIDMET").filterDate("2020-09-08", "2020-09-15") >>> col.wx.to_xarray(scale=40000, crs="EPSG:5070", nodata=-9999)