CQLFilter#

class geodesic.cql.CQLFilter(*args, **kwargs)[source]#

Represents an OGC CQL2 Filter.

The CQL2 standard is documented on the OGC’s github repo for the OGC API Features: opengeospatial/ogcapi-features

CQL2 is a way to filter tabular datasets such as features and STAC items. In Geodesic, we use CQL2 as the universal filtering language and it’s converted internally to the needed filtering format.

CQLFilter has only two keyword arguments, op and args, described below.

Parameters:
  • op – the name/id for the operation

  • args – a list of arguments for that operation

Filters can be composed of multiple filters using the and/or ops.

Examples

>>> from geodesic.cql import CQLFilter as C
>>> # filter a dataset for all items that have a value of "ASCENDING" for the field "properties.orbit"
>>> filter = C.eq("properties.orbit", "ASCENDING")
>>> # filter a dataset for all items that have a value of "ASCENDING" for the field "properties.orbit"
>>> # and a value of "properties.angle" of less than 45.0
>>> filter = C.and(C.eq("properties.orbit", "ASCENDING"), C.lt("properties.angle", 45.0))
>>> # Directly create a CQLFilter using CQL syntax. This is for items with a field "a" and a value equal to "b"
>>> from geodesic.cql import CQLFilter
>>> filter = CQLFilter(op="=", args=[{"property": "a"}, "b"])

Attributes

args

arguments to this operation

op

(str) - the operation this filter implements

Methods

between(property, a, b)

Filter that checks that a property is between two values.

clear()

copy()

eq(property, value)

Filter on equality between a property and a value.

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

gt(property, value)

Filter that a property is greater than a value.

gte(property, value)

Filter that a property is greater than or equal to a value.

isin(property, value)

Filter that checks for items in an array/list.

isnull(property)

Filter that checks that a field is null.

items()

keys()

like(property, value)

Filter that checks for text similarity.

logical_and(*args)

Filter that combines multiple filters with a logical and.

logical_not(filter)

Filter that negates another filter.

logical_or(*args)

Filter that combines multiple filters with a logical or.

lt(property, value)

Filter that a property is less than a value.

lte(property, value)

Filter that a property is less than or equal to a value.

neq(property, value)

Filter on no equality between a property and a value.

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update(*mapping, **kwargs)

values()