wxee.collection.ImageCollection.to_xarray

ImageCollection.to_xarray(path: str | None = None, region: Geometry | None = None, scale: int | None = None, crs: str = 'EPSG:4326', masked: bool = True, nodata: int = -32768, num_cores: int = -1, progress: bool = True, max_attempts: int = 10) Dataset[source]

Convert an image collection to an xarray.Dataset. The system:time_start property of each image in the collection is used to arrange 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 images within. If none is provided, the geometry of the image collection will be used. If geometry varies between images in the collection, the region will encompass all images which may lead to very large arrays and download limits.

  • scale (int, optional) – The scale to download the array at in the CRS units. If none is provided, the projection.nominalScale of the images 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.

  • num_cores (int, default -1) – The number of CPU cores to use for parallel operations. Defaults to -1 which will use all available cores.

  • 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 all images in the collection with an assigned time dimension and variables set from each image.

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)