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
ee.ImageCollectionas anxarray.Dataset.- Parameters:
drop_variables (str | Iterable[str] | None) – Variables or bands to drop before opening.
io_chunks (object) – 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 (bool | None) – 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 (bool | None) – 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 tocftime.datetimeobjects. If True, always decode times tocftime.datetimeobjects, regardless of whether or not they can be represented usingnp.datetime64[ns]objects. If False, always decode times tonp.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 (str | None) – 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 (float | int | None) – The scale in the
crsorprojection’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 (ee.Projection | None) – Specify an
ee.Projectionobject to define thescaleandcrs(or other coordinate reference system) with which to coalesce all variables upon opening. By default, the scale and reference system is set by thecrsandscalearguments.geometry (ee.Geometry | None) – Specify an
ee.Geometryto define the regional bounds when opening the data. When not set, the bounds are defined by the CRS’sarea_of_useboundaries. If those aren’t present, the bounds are derived from the geometry of the first image of the collection.primary_dim_name (str | None) – Override the name of the primary dimension of the output Dataset. By default, the name is ‘time’.
primary_dim_property (str | None) – Override the
ee.Imageproperty for which to derive the values of the primary dimension. By default, this is ‘system:time_start’.ee_mask_value (float | None) – 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.Datasetthat streams in remote data from Earth Engine.- Return type:
xarray.Dataset