geetools.ImageCollectionAccessor.to_xarray#

geetools.ImageCollectionAccessor.to_xarray(drop_variables=None, io_chunks=None, n_images=-1, mask_and_scale=True, decode_times=True, decode_timedelta=None, use_cftime=None, concat_characters=True, decode_coords=True, crs=None, scale=None, projection=None, geometry=None, primary_dim_name=None, primary_dim_property=None, ee_mask_value=None, request_byte_limit=REQUEST_BYTE_LIMIT)#

Open an Earth Engine ImageCollection as an xarray.Dataset.

Parameters:
  • drop_variables (Optional[Tuple[str, Ellipsis]]) – Variables or bands to drop before opening.

  • io_chunks (Optional[Any]) – Specifies the chunking strategy for loading data from EE. By default, this automatically calculates optional chunks based on the request_byte_limit.

  • n_images (int) – The max number of EE images in the collection to open. Useful when there are a large number of images in the collection since calculating collection size can be slow. -1 indicates that all images should be included.

  • mask_and_scale (bool) – Lazily scale (using scale_factor and add_offset) and mask (using _FillValue).

  • decode_times (bool) – Decode cf times (e.g., integers since “hours since 2000-01-01”) to np.datetime64.

  • decode_timedelta (Optional[bool]) – If True, decode variables and coordinates with time units in {“days”, “hours”, “minutes”, “seconds”, “milliseconds”, “microseconds”} into timedelta objects. If False, leave them encoded as numbers. If None (default), assume the same value of decode_time.

  • use_cftime (Optional[bool]) – Only relevant if encoded dates come from a standard calendar (e.g. “gregorian”, “proleptic_gregorian”, “standard”, or not specified). If None (default), attempt to decode times to np.datetime64[ns] objects; if this is not possible, decode times to cftime.datetime objects. If True, always decode times to cftime.datetime objects, regardless of whether or not they can be represented using np.datetime64[ns] objects. If False, always decode times to np.datetime64[ns] objects; if this is not possible raise an error.

  • concat_characters (bool) – Should character arrays be concatenated to strings, for example: [“h”, “e”, “l”, “l”, “o”] -> “hello”

  • decode_coords (bool) – bool or {“coordinates”, “all”}, Controls which variables are set as coordinate variables: - “coordinates” or True: Set variables referred to in the 'coordinates' attribute of the datasets or individual variables as coordinate variables. - “all”: Set variables referred to in 'grid_mapping', 'bounds' and other attributes as coordinate variables.

  • crs (Optional[str]) – The coordinate reference system (a CRS code or WKT string). This defines the frame of reference to coalesce all variables upon opening. By default, data is opened with ‘EPSG:4326’.

  • scale (Union[float, int, None]) – The scale in the crs or projection’s units of measure – either meters or degrees. This defines the scale that all data is represented in upon opening. By default, the scale is 1° when the CRS is in degrees or 10,000 when in meters.

  • projection (Optional[ee.Projection]) – Specify an ee.Projection object to define the scale and crs (or other coordinate reference system) with which to coalesce all variables upon opening. By default, the scale and reference system is set by the the crs and scale arguments.

  • geometry (Optional[ee.Geometry]) – Specify an ee.Geometry to define the regional bounds when opening the data. When not set, the bounds are defined by the CRS’s area_of_use boundaries. If those aren’t present, the bounds are derived from the geometry of the first image of the collection.

  • primary_dim_name (Optional[str]) – Override the name of the primary dimension of the output Dataset. By default, the name is ‘time’.

  • primary_dim_property (Optional[str]) – Override the ee.Image property for which to derive the values of the primary dimension. By default, this is ‘system:time_start’.

  • ee_mask_value (Optional[float]) – Value to mask to EE nodata values. By default, this is ‘np.iinfo(np.int32).max’ i.e. 2147483647.

  • request_byte_limit (int) – the max allowed bytes to request at a time from Earth Engine. By default, it is 48MBs.

Returns:

An xarray.Dataset that streams in remote data from Earth Engine.

Return type:

xarray.Dataset