easystac.base.ImageCollection¶
- class easystac.base.ImageCollection(collection)[source]¶
ImageCollection object for any kind of STAC.
This object mimics the Earth Engine filtering methods for ee.ImageCollection class and makes them available for any kind of STAC.
- Parameters
collection (str) – Collection name.
Examples
>>> import easystac as es >>> from geojson import Polygon >>> geom = Polygon([ >>> [ >>> [-122.1553, 38.7578], >>> [-121.8321, 39.7444], >>> [-123.0002, 39.7503], >>> [-123.0002, 38.7609], >>> [-122.1553, 38.7578] >>> ] >>> ] >>> ) >>> HLSS30 = (es.ImageCollection("HLSS30.v2.0") >>> .fromSTAC("https://cmr.earthdata.nasa.gov/stac/LPCLOUD/") >>> .filterBounds(geom) >>> .filterDate("2021-01-01","2022-01-01") >>> .getInfo(epsg = 4326,resolution = 0.0001,assets = ["B02","B03","B04"]))
Methods
fromSTAC(url)Initializes the STAC for querying.
filterDate(initialDate, finalDate)Initializes the initial and final date for datetime filtering.
filterBounds(geometry)Initializes the geometry for bounds filtering.
getInfo(**kwargs)Returns all the information from the STAC search.
- fromSTAC(url)[source]¶
Initializes the STAC for querying.
- Parameters
url (str) – STAC Catalog url.
- Return type
Examples
>>> import easystac as es >>> HLSS30 = (es.ImageCollection("HLSS30.v2.0") >>> .fromSTAC("https://cmr.earthdata.nasa.gov/stac/LPCLOUD/")
- filterDate(initialDate, finalDate)¶
Initializes the initial and final date for datetime filtering.
- Parameters
initialDate (str) – Initial date in format %Y-%m-%d.
finalDate (str) – Final date in format %Y-%m-%d.
- Return type
BaseImageCollection
Examples
>>> import easystac.planetary as pc >>> pc.Authenticate() >>> pc.Initialize() >>> S2 = (pc.ImageCollection("sentinel-2-l2a") .filterDate("2020-01-01","2021-01-01"))
- filterBounds(geometry)¶
Initializes the geometry for bounds filtering.
- Parameters
geometry (dict) – GeoJSON object of dictionary-like object representing a GeoJSON.
- Return type
BaseImageCollection
Examples
>>> import easystac.planetary as pc >>> from geojson import Point >>> pc.Authenticate() >>> pc.Initialize() >>> geom = Point([-76.1,4.3]) >>> S2 = (pc.ImageCollection("sentinel-2-l2a") .filterBounds(geom))
- getInfo(**kwargs)[source]¶
Returns all the information from the STAC search.
- Parameters
**kwargs – Additional arguments passed to
stackstac.stack(). Some of them areepsg,resolution, andbbox.- Returns
Chunked DataArray with Dask.
- Return type
xarray.DataArray
Examples
>>> import easystac as es >>> from geojson import Polygon >>> geom = Polygon([ >>> [ >>> [-122.1553, 38.7578], >>> [-121.8321, 39.7444], >>> [-123.0002, 39.7503], >>> [-123.0002, 38.7609], >>> [-122.1553, 38.7578] >>> ] >>> ] >>> ) >>> HLSS30 = (es.ImageCollection("HLSS30.v2.0") >>> .fromSTAC("https://cmr.earthdata.nasa.gov/stac/LPCLOUD/") >>> .filterBounds(geom) >>> .filterDate("2021-01-01","2022-01-01") >>> .getInfo(epsg = 4326,resolution = 0.0001,assets = ["B02","B03","B04"]))