cubo.cubo.create¶
- cubo.cubo.create(lat: float | int, lon: float | int, collection: str, start_date: str, end_date: str, bands: str | List[str] | None = None, edge_size: float | int = 128.0, units: str = 'px', resolution: float | int = 10.0, stac: str = 'https://planetarycomputer.microsoft.com/api/stac/v1', gee: bool = False, stackstac_kw: dict | None = None, **kwargs) DataArray [source]¶
Creates a data cube from a STAC Catalogue as a
xr.DataArray
object.The coordinates used here work as the approximate central coordinates of the data cube in the spatial dimension.
- Parameters:
lat (float | int) – Latitude of the central pixel of the data cube.
lon (float | int) – Longitude of the central pixel of the data cube.
collection (str) – Name of the collection in the STAC Catalogue.
start_date (str) – Start date of the data cube in YYYY-MM-DD format.
end_date (str) – End date of the data cube in YYYY-MM-DD format.
bands (str | List[str], default = None) – Name of the band(s) from the collection to use.
edge_size (float | int, default = 128) –
Size of the edge of the cube in the units specified by
units
. All edges share the same size.Warning
If
edge_size
is not a multiple of 2, it will be rounded.units (str, default = 'px') –
Units of the provided edge size in
edge_size
. Must be ‘px’ (pixels), ‘m’ (meters), or a unit name in https://docs.scipy.org/doc/scipy/reference/constants.html#units.Added in version 2024.1.1.
Warning
Note that when
units!='px'
the edge size will be transformed to meters (ifunits!='m'
). Furthermore, the edge size will be converted to pixels (usingedge_size/resolution
) and rounded (seeedge_size
). Therefore, the edge size whenunits!='px'
is just an approximation if its value in meters is not divisible by the requested resolution.resolution (float | int, default = 10) – Pixel size in meters.
stac (str, default = ‘https://planetarycomputer.microsoft.com/api/stac/v1’) – Endpoint of the STAC Catalogue to use.
gee (bool, default = True) –
Whether to use Google Earth Engine. This ignores the ‘stac’ argument.
Added in version 2024.1.0.
stackstac_kw (dict, default = None) –
Keyword arguments for
stackstac
as a dictionary.Added in version 2024.1.0.
kwargs – Additional keyword arguments passed to
pystac_client.Client.search()
.
- Returns:
Data Cube.
- Return type:
xr.DataArray
Examples
Create a Sentinel-2 L2A data cube with an edge size of 64 px from Planetary Computer:
>>> import cubo >>> cubo.create( ... lat=50, ... lon=10, ... collection="sentinel-2-l2a", ... bands=["B02","B03","B04"], ... start_date="2021-06-01", ... end_date="2021-06-10", ... edge_size=32, ... resolution=10, ... ) <xarray.DataArray (time: 3, band: 3, x: 32, y: 32)>
Create a Sentinel-2 L2A data cube with an edge size of 128 px from Google Earth Engine:
>>> import cubo >>> cubo.create( ... lat=51.079225, ... lon=10.452173, ... collection="COPERNICUS/S2_SR_HARMONIZED", ... bands=["B2","B3","B4"], ... start_date="2016-06-01", ... end_date="2017-07-01", ... edge_size=128, ... resolution=10, ... gee=True, ... ) <xarray.DataArray (time: 27, band: 3, x: 128, y: 128)>