Common Query Language (CQL2) is a filter grammar that can be used for STAC item search.
A CQL2 filter consists of rules. Rules consist of arguments and operators. An argument is a value of a specific property you can choose from available filter parameters.
Parameter | Overview |
---|---|
filter | object A CQL2 filter. |
filter.args | array of objects Arguments inside of a CQL2 filter. |
filter.op | string Operators inside of a CQL2 filter. |
Create a CQL2 filter for the /v2/assets/stac/search endpoint as follows:
- Find queryable filter parameters by calling the /v2/assets/stac/queryables endpoint.
- In
filter.args
, use a queryable filter parameter in the nestedproperty
field and follow it with a value. - In
filter.op
, add an operator.
An example of a filter that searches for STAC items with cloud coverage less than 20%:
JSON
{
"filter": {
"op": "<",
"args": [
{
"property": "eo:cloud_cover"
},
20.0
]
}
}
+
: addition-
: subtraction*
: multiplication/
: division
a_contains
: search for STAC items that contain all array values in their parameters.a_overlaps
: search for STAC items that contain at least one array value in their parameters.
An example with a_contains
Returns STAC items with both optical
and aerial
in their tags.
JSON
{
"filter": {
"op": "a_contains",
"args": [
{
"property": "tags"
},
["optical", "aerial"]
]
}
}
An example with a_overlaps
Returns STAC items with either optical
or aerial
in their tags.
JSON
{
"filter": {
"op": "a_overlaps",
"args": [
{
"property": "tags"
},
["optical", "aerial"]
]
}
}
=
: equal to!=
: not equal to<
: less than>
: greater than<=
: less than or equal to>=
: greater than or equal toisNull
: the value is null
An example with >
Returns STAC items with cloud coverage of more than 20%.
JSON
{
"filter": {
"op": ">",
"args": [
{
"property": "eo:cloud_cover"
},
20.0
]
}
}
An example with isNull
Returns STAC items with no tags.
JSON
{
"filter": {
"op": "isNull",
"args": {
"property": "tags"
}
}
}
and
: search for STAC items whose parameter values satisfy both arguments.or
: search for STAC items whose parameter values satisfy any of the arguments.not
: exclude STAC items whose parameter values satisfy the argument.
An example with and
Returns STAC items that have a ground sample distance less than or equal to 70 cm, and cloud coverage less than or equal to 20%.
JSON
{
"filter": {
"op": "and",
"args": [
{
"op": "<=",
"args": [
{
"property": "gsd"
},
0.7
]
},
{
"op": "<=",
"args": [
{
"property": "eo:cloud_cover"
},
20.0
]
}
]
}
}
An example with or
Returns STAC items that either have "constellation": "PNEO"
or "collection_name": "pneo-tasking"
in their parameters.
JSON
{
"filter": {
"op": "or",
"args": [
{
"op": "=",
"args": [
{
"property": "constellation"
},
"PNEO"
]
},
{
"op": "=",
"args": [
{
"property": "collection_name"
},
"pneo-tasking"
]
}
]
}
}
An example with not
Returns STAC items that don’t have "constellation": "PNEO"
in their parameters.
JSON
{
"filter": {
"op": "not",
"args": [
{
"op": "=",
"args": [
{
"property": "constellation"
},
"PNEO"
]
}
]
}
}
s_contains
s_crosses
s_disjoint
s_equals
s_intersects
s_overlaps
s_touches
s_within
An example with s_within
Returns STAC items whose AOIs are within the defined polygon.
JSON
{
"filter": {
"op": "s_within",
"args": [
{
"property": "geometry"
},
{
"type": "Polygon",
"coordinates": [
[
[-123.47593244349214, 48.65881246874093],
[-123.44562410769204, 48.65893370548264],
[-123.44429739341179, 48.658161559812235],
[-123.44376648785145, 48.65522725021609],
[-123.47599504628167, 48.655076990420135],
[-123.47602614621897, 48.65838026437638],
[-123.47601340902926, 48.658758157043785],
[-123.47593244349214, 48.65881246874093],
[-123.47593244349214, 48.65881246874093]
]
]
}
]
}
}
An example with s_touches
Returns STAC items whose AOIs touch the defined line.
JSON
{
"filter": {
"op": "s_touches",
"args": [
{
"property": "geometry"
},
{
"type": "Point",
"coordinates": [-123.47593244349214, 48.65881246874093]
}
]
}
}
Use date and time in the ISO 8601 format: YYYY‐MM‐DDThh:mm:ssZ
t_after
t_before
t_contains
t_during
t_equals
t_finishes
t_finishedby
t_meets
t_metby
t_overlaps
t_overlappedby
t_starts
t_startedby
An example with t_before
Returns STAC items acquired before March 21, 2023.
JSON
{
"filter": {
"op": "t_before",
"args": [
{
"property": "datetime"
},
"2023-03-21T00:00:00.000Z"
]
}
}
An example with t_overlaps
Returns STAC items acquired between March 21, 2023, and April 18, 2023.
JSON
{
"filter": {
"op": "t_overlaps",
"args": [
{
"property": "datetime"
},
{
"interval": ["2021-03-21T00:00:00.000Z", "2023-04-18T00:00:00.000Z"]
}
]
}
}