The Python API to Astraea's Earth OnDemand Catalog has 3 primary query functions:
collections() -> DataFrame
item_assets(c: collection) -> DataFrame
read_catalog(**query) -> GeoDataFrame
The ordering used above goes from most general to most specific. collections
provides a list of the major datasets available in Earth OnDemand. assets
describes the individual, discrete components of a data set, such as bands, metadata files, thumbnails, etc. Finally, read_catalog
performs a spatiotemporal search over the catalog, delivering URIs to "assets" matching the query.
In the example below we will show examples of each of these. Further information can be found in the Earth OnDemand section of the EarthAI Users' Manual.
# Import the requisite module functions. from earthai.earth_ondemand import * import pandas as pd # Turn off column truncation in Pandas. pd.set_option('display.max_colwidth', -1)
The first query the available collections in Earth OnDemand and look at the schema to see the additional metadata available to us:
c = collections() c.info() display(c[['familyTitle', 'id', 'description']])
Next, we'll take a look at the "assets" available in one of the collections, landsat8_c2l1t1
.
item_assets('landsat8_c2l1t1')
Now that we know what assets are available in the landsat8_c2l1t1
collection, we can perform our query and select the specific bands we care about. For example, if we want "red" and "nir" for computing NDVI, we'll select bands B4
(red) and B5
(NIR).
There are two different approaches to performing our search. The first is to perform a "code based query" in Python:
search_results1 = read_catalog( collections='landsat8_c2l1t1', geo=[ -122.5456, 37.602333, -122.339630, 37.82193606 ], max_cloud_cover=10, start_datetime='2020-01-01', end_datetime='2020-04-25' ) search_results1[['B4', 'B5']]
The second approach is to use the %%eod
magic, which allows you to use a web-based query exported from the Earth OnDemand web application.
%%eod --name search_results2 { "collections": [ "landsat8_c2l1t1" ], "geo": [ -122.5456, 37.602333, -122.339630, 37.82193606 ], "max_cloud_cover": 10, "start_datetime": "2020-01-01T00:00:00.000Z", "end_datetime": "2020-04-25T00:00:00.000Z" }
search_results2[['B4', 'B5']]
Comments
0 comments
Please sign in to leave a comment.