wcps.model

This module defines classes and methods for dynamically building WCPS query expressions.

This can be done by:

  1. Composing objects of WCPSExpr subclasses, e.g. Sum(Datacube(“cube”))

  2. Chaining methods on WCPSExpr objects, e.g. Datacube(“cube”).sum()

Each subclass defines the __str__ method, so that executing str(Sum(Datacube("cube"))) returns a valid WCPS query string that can be sent to a WCPS server.

Attributes

BoundType

A type representing axis bounds (in subsetting, extend, scale, etc).

ScalarType

Scalar values can be of one of these types.

OperandType

Type of operands of WCPS expressions.

AxisTuple

Axis tuple types: (name, low), (name, low, high), or (name, low, high, crs)

Exceptions

WCPSClientException

An exception thrown by this library.

Classes

StrEnum

Custom implementation of StrEnum for Python <= 3.10

WCPSExpr

An abstract class encapsulating a WCPS expression.

Datacube

A reference to a datacube (coverage) object on a WCPS server.

Scalar

A wrapper for scalar values, e.g. 5, 3.14, "PNG".

UnaryOp

A base class for unary operators, e.g. logical NOT.

BinaryOp

A base class for binary operators, e.g. logical AND.

UnaryFunc

A base class for unary functions, e.g. Abs.

BinaryFunc

A base class for binary functions, e.g. Pow.

Add

Adds op1 to op2.

Sub

Subtracts op2 from op1.

Mul

Multiplies op1 by op2.

Div

Divides op1 by op2.

Mod

Computes the modulus (remainder of the division) of op1 by op2.

Abs

Computes the absolute value of op.

Round

Rounds op to the nearest integer.

Floor

Computes the floor of op (rounds down to the nearest integer).

Ceil

Computes the ceiling of op (rounds up to the nearest integer).

Exp

Computes the exponential (e^x) of op.

Log

Computes the logarithm (base 10) of op.

Ln

Computes the natural logarithm (base e) of op.

Sqrt

Computes the square root of op.

Pow

Raises op1 to the power of op2.

Sin

Computes the sine of op.

Cos

Computes the cosine of op.

Tan

Computes the tangent of op.

Sinh

Computes the hyperbolic sine of op.

Cosh

Computes the hyperbolic cosine of op.

Tanh

Computes the hyperbolic tangent of op.

ArcSin

Computes the inverse sine of op.

ArcCos

Computes the inverse cosine of op.

ArcTan

Computes the inverse tangent of op.

ArcTan2

Computes the two-argument inverse tangent of op.

Gt

Checks if op1 is greater than op2.

Lt

Checks if op1 is less than op2.

Ge

Checks if op1 is greater than or equal to op2.

Le

Checks if op1 is less than or equal to op2.

Eq

Checks if op1 is equal to op2.

Ne

Checks if op1 is not equal to op2.

And

Performs a logical AND operation between op1 and op2.

Or

Performs a logical OR operation between op1 and op2.

Xor

Performs a logical XOR operation between op1 and op2.

Not

Performs a logical Not operation on op.

Overlay

Performs an overlay operation, placing op2 "on top" of op1:

Bit

Take the bit in the cell values of op at nonnegative position number pos,

Band

Select a field (band, channel) from a multiband operand.

MultiBand

Create a multiband value.

Axis

Represents an axis interval for defining spatial, temporal, or other dimensional subsets

Subset

Select a spatio-temporal area from a coverage operand.

Extend

Enlarge a coverage with new areas set to null values.

Scale

Resamples the coverage values to fit a new domain. The target domain can be:

ResampleAlg

Possible interpolation methods for Reproject.

Reproject

Reproject a coverage to a different CRS.

CastType

Possible cell types to which a value can be casted.

Cast

Cast a value to a new type. The type can be specified with the to() method.

Sum

Computes the sum of the cell values of the operand op.

Count

Counts the number of true values in the boolean operand op.

Avg

Computes the average (mean) of the cell values of the operand op.

Min

Returns the minimum value among the elements of the operand op.

Max

Returns the maximum value among the elements of the operand op.

All

Returns true if all elements in the operand op are true.

Some

Returns true if some elements in the operand op are true.

AxisIter

An axis iterator expression set in a Condense.over() or a Coverage.over() methods.

AxisIterRef

Reference to an AxisIter object, to be used in expressions set in the

CondenseOp

Possible general Condense operators.

Condense

A general coverage condense (aggregation) operation. It aggregates values over()

Coverage

A general coverage constructor operation. It allows to create a coverage over() a

Switch

Perform a switch operation for conditional evaluation. This produces a WCPS query

Clip

Clip op with the given WKT string. For supported WKT parameters see

Udf

Execute a user-defined function (UDF), or any other WCPS function for which

Encode

Encode a coverage to some data format. The data format must be specified

Functions

rgb(r, g, b)

Utility method for conveniently specifying RGB (red, green, blue) multiband values.

rgba(r, g, b, a)

Utility method for conveniently specifying RGBA (red, green, blue, alpha) multiband values.

Module Contents

class StrEnum[source]

Bases: str, enum.Enum

Custom implementation of StrEnum for Python <= 3.10

Initialize self. See help(type(self)) for accurate signature.

class WCPSExpr(operands=None)[source]

An abstract class encapsulating a WCPS expression.

It contains a list of operands (themselves WCPSExpr) and a parent.

Subclasses for each operator exist, e.g. Add for binary addition, which are applied to the operands. For most operators there are also corresponding methods in this class, allowing to build an expression by chaining them, e.g Sum(Datacube("cube1") + Datacube("cube2")) is the same as Datacube("cube1").add(Datacube("cube2").sum()). Notable exceptions are Switch and Coverage.

Various builtin operators are overloaded to allow writing expressions more naturally, e.g. WCPSExpr * WCPSExpr. Number/strings are automatically wrapped in a Scalar, e.g. WCPSExpr * 2 becomes WCPSExpr * Scalar(2).

__and__, __or__, __xor__, __invert__ correspond to BITWISE operators, not to the logical and, or, and not. They are not overloaded to the logical and/or/xor/not in order to avoid confusion.

Parameters:

operands (Optional[OperandType | list[OperandType]]) – the operands of this WCPS expression. This object is set as the parent of each operand, while its own parent is set to None. Scalar operands such as 1, 4.9 or “test” are automatically wrapped in a Scalar object.

parent: WCPSExpr | None = None[source]

A WCPSExpr of which this expression is an operand; None if this is the root expression. E.g. in if this expression is the Datacube object in Datacube("test") * 5, then the parent is the Mul object.

operands: list[WCPSExpr] = [][source]

A list of WCPSExpr operands of this expressions. E.g. in Datacube("test") * 5, this expression is a Mul, with Datacube and Scalar operands.

get_datacube_operands()[source]
Returns:

all unique Datacube objects contained within the expression tree starting from this WCPSExpr, sorted alphabetically by datacube name.

Return type:

list[Datacube]

add_operand(op)[source]

Add an operand to the list of operands. Scalar op such as 1, 4.9 or “test” are automatically wrapped in a Scalar object. :param op: an operand to be added to the list of this expression’s operands; if op is None it will be ignored.

Parameters:

op (OperandType)

add(other)[source]

Adds the current operand to another operand.

Parameters:

other (OperandType) – The operand to add to the current operand.

Returns:

An instance of the Add class representing the addition operation.

Return type:

Add

Examples:

  • Datacube("test1").add(Datacube("test2"))

  • Datacube("test1").add(5)

sub(other)[source]

Subtracts another operand from the current operand.

Parameters:

other (OperandType) – The operand to subtract from the current operand.

Returns:

An instance of the Sub class representing the subtraction operation.

Return type:

Sub

Examples:

  • Datacube("test1").sub(Datacube("test2"))

  • Datacube("test1").sub(5)

mul(other)[source]

Multiplies the current operand by another operand.

Parameters:

other (OperandType) – The operand to multiply with the current operand.

Returns:

An instance of the Mul class representing the multiplication operation.

Return type:

Mul

Examples:

  • Datacube("test1").mul(Datacube("test2"))

  • Datacube("test1").mul(5)

div(other)[source]

Divides the current operand by another operand.

Parameters:

other (OperandType) – The operand to divide the current operand by.

Returns:

An instance of the Div class representing the division operation.

Return type:

Div

Examples:

  • Datacube("test1").div(Datacube("test2"))

  • Datacube("test1").div(5)

mod(other)[source]

Computes the modulus (remainder of the division) of the current operand by another operand.

Parameters:

other (OperandType) – The operand to use as the divisor.

Returns:

An instance of the Mod class representing the modulus operation.

Return type:

Mod

Examples:

  • Datacube("test1").mod(Datacube("test2"))

  • Datacube("test1").mod(5)

abs()[source]

Computes the absolute value of the current operand.

Returns:

An instance of the Abs class representing the absolute value operation.

Return type:

Abs

Examples:

  • Datacube("test1").abs()

round()[source]

Rounds the current operand to the nearest integer.

Returns:

An instance of the Round class representing the rounding operation.

Return type:

Round

Examples:

  • Datacube("test1").round()

floor()[source]

Computes the floor of the current operand (rounds down to the nearest integer).

Returns:

An instance of the Floor class representing the floor operation.

Return type:

Floor

Examples:

  • Datacube("test1").floor()

ceil()[source]

Computes the ceiling of the current operand (rounds up to the nearest integer).

Returns:

An instance of the Ceil class representing the ceiling operation.

Return type:

Ceil

Examples:

  • Datacube("test1").ceil()

exp()[source]

Computes the exponential (e^x) of the current operand.

Returns:

An instance of the Exp class representing the exponential operation.

Return type:

Exp

Examples:

  • Datacube("test1").exp()

log()[source]

Computes the logarithm (base 10) of the current operand.

Returns:

An instance of the Log class representing the logarithm operation.

Return type:

Log

Examples:

  • Datacube("test1").log()

ln()[source]

Computes the natural logarithm (base e) of the current operand.

Returns:

An instance of the Ln class representing the natural logarithm operation.

Return type:

Ln

Examples:

  • Datacube("test1").ln()

sqrt()[source]

Computes the square root of the current operand.

Returns:

An instance of the Sqrt class representing the square root operation.

Return type:

Sqrt

Examples:

  • Datacube("test1").sqrt()

pow(other)[source]

Raises the current operand to the power of another operand.

Parameters:

other (OperandType) – The exponent to raise the current operand to.

Returns:

An instance of the Pow class representing the power operation.

Return type:

Pow

Examples:

  • Datacube("test1").pow(Datacube("test2"))

  • Datacube("test1").pow(5)

sin()[source]

Computes the sine of the current operand.

Returns:

An instance of the Sin class representing the sine operation.

Return type:

Sin

Examples:

  • Datacube("test1").sin()

cos()[source]

Computes the cosine of the current operand.

Returns:

An instance of the Cos class representing the cosine operation.

Return type:

Cos

Examples:

  • Datacube("test1").cos()

tan()[source]

Computes the tangent of the current operand.

Returns:

An instance of the Tan class representing the tangent operation.

Return type:

Tan

Examples:

  • Datacube("test1").tan()

sinh()[source]

Computes the hyperbolic sine of the current operand.

Returns:

An instance of the Sinh class representing the hyperbolic sine operation.

Return type:

Sinh

Examples:

  • Datacube("test1").sinh()

cosh()[source]

Computes the hyperbolic cosine of the current operand.

Returns:

An instance of the Cosh class representing the hyperbolic cosine operation.

Return type:

Cosh

Examples:

  • Datacube("test1").cosh()

tanh()[source]

Computes the hyperbolic tangent of the current operand.

Returns:

An instance of the Tanh class representing the hyperbolic tangent operation.

Return type:

Tanh

Examples:

  • Datacube("test1").tanh()

arcsin()[source]

Computes the inverse sine (arcsine) of the current operand.

Returns:

An instance of the ArcSin class representing the arcsine operation.

Return type:

ArcSin

Examples:

  • Datacube("test1").arcsin()

arccos()[source]

Computes the inverse cosine (arccosine) of the current operand.

Returns:

An instance of the ArcCos class representing the arccosine operation.

Return type:

ArcCos

Examples:

  • Datacube("test1").arccos()

arctan()[source]

Computes the inverse tangent (arctangent) of the current operand.

Returns:

An instance of the ArcTan class representing the arctangent operation.

Return type:

ArcTan

Examples:

  • Datacube("test1").arctan()

arctan2()[source]

Computes the two-argument inverse tangent (arctangent2) of the current operand.

Returns:

An instance of the ArcTan2 class representing the arctangent2 operation.

Return type:

ArcTan2

Examples:

  • Datacube("test1").arctan2(Datacube("test2"))

gt(other)[source]

Checks if the current operand is greater than another operand.

Parameters:

other (OperandType) – The operand to compare against.

Returns:

An instance of the Gt class representing the greater-than comparison.

Return type:

Gt

Examples:

  • Datacube("test1").gt(Datacube("test2"))

  • Datacube("test1").gt(10)

lt(other)[source]

Checks if the current operand is less than another operand.

Parameters:

other (OperandType) – The operand to compare against.

Returns:

An instance of the Lt class representing the less-than comparison.

Return type:

Lt

Examples:

  • Datacube("test1").lt(Datacube("test2"))

  • Datacube("test1").lt(10)

ge(other)[source]

Checks if the current operand is greater than or equal to another operand.

Parameters:

other (OperandType) – The operand to compare against.

Returns:

An instance of the Ge class representing the greater-than-or-equal-to comparison.

Return type:

Ge

Examples:

  • Datacube("test1").ge(Datacube("test2"))

  • Datacube("test1").ge(10)

le(other)[source]

Checks if the current operand is less than or equal to another operand.

Parameters:

other (OperandType) – The operand to compare against.

Returns:

An instance of the Le class representing the less-than-or-equal-to comparison.

Return type:

Le

Examples:

  • Datacube("test1").le(Datacube("test2"))

  • Datacube("test1").le(10)

eq(other)[source]

Checks if the current operand is equal to another operand.

Parameters:

other (OperandType) – The operand to compare against.

Returns:

An instance of the Eq class representing the equality comparison.

Return type:

Eq

Examples:

  • Datacube("test1").eq(Datacube("test2"))

  • Datacube("test1").eq(10)

ne(other)[source]

Checks if the current operand is not equal to another operand.

Parameters:

other (OperandType) – The operand to compare against.

Returns:

An instance of the Ne class representing the inequality comparison.

Return type:

Ne

Examples:

  • Datacube("test1").ne(Datacube("test2"))

  • Datacube("test1").ne(10)

logical_and(other)[source]

Performs a logical AND operation between the current operand and another operand.

Parameters:

other (OperandType) – The operand to perform the AND operation with.

Returns:

An instance of the And class representing the logical AND operation.

Return type:

And

Examples:

  • Datacube("test1").logical_and(Datacube("test2"))

  • Datacube("test1").logical_and(True)

logical_or(other)[source]

Performs a logical OR operation between the current operand and another operand.

Parameters:

other (OperandType) – The operand to perform the OR operation with.

Returns:

An instance of the Or class representing the logical OR operation.

Return type:

Or

Examples:

  • Datacube("test1").logical_or(Datacube("test2"))

  • Datacube("test1").logical_or(False)

logical_xor(other)[source]

Performs a logical XOR operation between the current operand and another operand.

Parameters:

other (OperandType) – The operand to perform the XOR operation with.

Returns:

An instance of the Xor class representing the logical XOR operation.

Return type:

Xor

Examples:

  • Datacube("test1").logical_xor(Datacube("test2"))

  • Datacube("test1").logical_xor(True)

logical_not()[source]

Performs a logical NOT operation on the current operand.

Returns:

An instance of the Not class representing the logical NOT operation.

Return type:

Not

Examples:

  • Datacube("test1").logical_not()

overlay(other)[source]

Performs an overlay operation, placing other operand “on top” of this operand:

  • wherever the second operand’s cell value is not zero and not null, the result value will be this value.

  • wherever the second operand’s cell value is zero or null, the first argument’s cell value will be taken.

Parameters:

other (OperandType) – The operand to perform the overlay operation with.

Returns:

An instance of the Overlay class representing the overlay operation.

Return type:

Overlay

Examples:

  • Datacube("test1").overlay(Datacube("test2"))

bit(pos)[source]

Take the bit in this operand’s cell values at nonnegative position number pos, and put it as a Boolean value into a byte. Position counting starts with 0 and runs from least to most significant bit.

Parameters:

pos (OperandType) – The position at which the bit value should be extracted

Returns:

An instance of the Bit class

Return type:

Bit

Examples:

  • Datacube("test1").bit(5)

band(band_name)[source]

Extract the given band band_name from this multiband object.

Parameters:

band_name – The band name or position (0-based index)

Returns:

An instance of the Band class

Return type:

Band

Examples:

  • Datacube("rgb").band("red")

  • Datacube("rgb").band(0)

subset(axes)[source]

Extract a spatio-temporal subset from this object as specified by the list of axes.

Parameters:

axes – specifies a spatio-temporal subset as:

Return type:

Subset

  1. a single Axis object: Axis(axis_name, low, high?, crs?)

  2. a tuple of multiple Axis objects: (Axis(...), Axis(...))

  3. a tuple specifying the axis subset in place: (axis_name, low, high?, crs?)

  4. a tuple of axis subset tuples (see 3.): ((axis_name, low, high?, crs?), (...), ...)

  5. a list of Axis objects: [Axis(…), Axis(…), …]

  6. a list of axis subset tuples (see 3.): [(axis_name, low, high?, crs?), (...), ...]

Returns:

An instance of the Subset class

Return type:

Subset

Examples (with cov = Datacube("testcube")):

  1. cov.subset(Axis("X", 5.5, 10.5))

  2. cov.subset(Axis("X", 5.5, 10.5), Axis("Y", 15))

  3. cov.subset("X", 5.5, 10.5)

  4. cov.subset(("X", 5.5, 10.5), ("Y", 15))

  5. cov.subset([Axis("X", 5.5, 10.5), Axis("Y", 15)])

  6. cov.subset([("X", 5.5, 10.5), ("Y", 15)])

extend(axes)[source]

Extend this object to a new domain as specified by the list of axes; new areas are filled in with null values.

Parameters:

axes – specifies a spatio-temporal subset as:

Return type:

Extend

  1. a single Axis object: Axis(axis_name, low, high?, crs?)

  2. a tuple of multiple Axis objects: (Axis(...), Axis(...))

  3. a tuple specifying the axis subset in place: (axis_name, low, high?, crs?)

  4. a tuple of axis subset tuples (see 3.): ((axis_name, low, high?, crs?), (...), ...)

  5. a list of Axis objects: [Axis(…), Axis(…), …]

  6. a list of axis subset tuples (see 3.): [(axis_name, low, high?, crs?), (...), ...]

Returns:

An instance of the Subset class

Return type:

Extend

Examples (with cov = Datacube("testcube")):

  1. cov.extend(Axis("X", 5.5, 10.5))

  2. cov.extend(Axis("X", 5.5, 10.5), Axis("Y", 15))

  3. cov.extend("X", 5.5, 10.5)

  4. cov.extend(("X", 5.5, 10.5), ("Y", 15))

  5. cov.extend([Axis("X", 5.5, 10.5), Axis("Y", 15)])

  6. cov.extend([("X", 5.5, 10.5), ("Y", 15)])

scale(grid_axes=None, another_coverage=None, single_factor=None, axis_factors=None)[source]

Up or down-scale the current object. Exactly one of the parameters must be specified.

Parameters:
  • grid_axes – rescale to the grid bounds specified for each axis

  • another_coverage – rescale to the domain of another coverage operand

  • single_factor – rescale all axes by the same scale factor; factor > 1 for scaling up, 0 < factor < 1 for scaling down

  • axis_factors – rescale each axis by a specific factor; factor > 1 for scaling up, 0 < factor < 1 for scaling down

Returns:

An instance of the Scale class

Raise:

A WCPSClientException in case of error in the provided arguments.

Return type:

Scale

Examples (with cov = Datacube("testcube")):

  1. cov.scale(("X", 0, 100), ("Y", 0, 200))

  2. cov.scale(Datacube("cov2"))

  3. cov.scale(0.5) - downscale by 2x

  4. cov.scale([0.5, 2]) - downscale the first axis by 2x, and upscale the second axis by 2x

reproject(target_crs, interpolation_method=None, axis_resolutions=None, axis_subsets=None, domain_of_coverage=None)[source]

Reproject the current object to a new CRS.

Parameters:
  • target_crs (str) – the new CRS, e.g. “EPSG:4326”

  • interpolation_method (str) – an optional interpolation method, one of the constants defined by ResampleAlg, e.g. ResampleAlg.BILINEAR

  • axis_resolutions – optional list of target axis resolutions to maintain in the reprojected result

  • axis_subsets – crop the result by the specified axis subsets (same syntax as for subset(axes))

  • domain_of_coverage – crop the result to the geo domain of another coverage object

Return type:

Reproject

Examples (with cov = Datacube("testcube")):

  1. cov.reproject("EPSG:4326")

  2. cov.reproject("EPSG:4326", interpolation_method=ResampleAlg.CUBIC)

  3. cov.reproject("EPSG:4326", axis_resolutions=[0.5, 1.5])

  4. cov.reproject("EPSG:4326", axis_subsets=[("Lat", 30.5, 60.5), ("Lon", 50.5, 70.5)])

  5. cov.reproject("EPSG:4326", axis_resolutions=[0.5, 1.5], domain_of_coverage=Datacube("cov2"))

cast(target_type)[source]

Cast the cell values of the current operand to a new target_type.

Parameters:

target_type (CastType) – the new cell type of the result, one of the constants in CastType, e.g. CastType.CHAR.

Return type:

Cast

Examples:

  • cov.cast(Datacube("testcube"), CastType.FLOAT)

sum()[source]

Computes the sum of the cell values of the current operand.

Returns:

An instance of the Sum class representing the sum operation.

Return type:

Sum

Examples:

  • Datacube("test1").sum()

count()[source]

Counts the number of true values in the current boolean coverage operand.

Returns:

An instance of the Count class representing the count operation.

Return type:

Count

Examples:

  • Datacube("test1").count()

avg()[source]

Computes the average (mean) of the cell values of the current operand.

Returns:

An instance of the Avg class representing the average operation.

Return type:

Avg

Examples:

  • Datacube("test1").avg()

min()[source]

Finds the minimum value among the elements of the current operand.

Returns:

An instance of the Min class representing the minimum operation.

Return type:

Min

Examples:

  • Datacube("test1").min()

max()[source]

Finds the maximum value among the elements of the current operand.

Returns:

An instance of the Max class representing the maximum operation.

Return type:

Max

Examples:

  • Datacube("test1").max()

all()[source]

Checks if all elements in the current operand are true.

Returns:

An instance of the All class.

Return type:

All

Examples:

  • Datacube("test1").all()

some()[source]

Checks if some elements in the current operand are true.

Returns:

An instance of the Some class.

Return type:

Some

Examples:

  • Datacube("test1").some()

encode(data_format=None, format_params=None)[source]

Encode a coverage to some data_format. The data format must be specified with the to(format) method if it isn’t provided here. Optionally format parameters can be specified to customize the encoding process.

Parameters:
  • data_format (str) – the data format, e.g. "GTiff"

  • format_params (str) – additional format parameters the influence the encoding

Return type:

Encode

Examples:

` Datacube("testcube").encode("GTiff").params("...") `

BoundType[source]

A type representing axis bounds (in subsetting, extend, scale, etc).

ScalarType[source]

Scalar values can be of one of these types.

OperandType[source]

Type of operands of WCPS expressions.

AxisTuple[source]

Axis tuple types: (name, low), (name, low, high), or (name, low, high, crs)

class Datacube(name)[source]

Bases: WCPSExpr

A reference to a datacube (coverage) object on a WCPS server.

Example: Datacube("mycoverage").

Parameters:

name (str) – the datacube (coverage) name.

name[source]
class Scalar(op)[source]

Bases: WCPSExpr

A wrapper for scalar values, e.g. 5, 3.14, "PNG".

Parameters:

op (ScalarType)

op[source]
class UnaryOp(op, operator)[source]

Bases: WCPSExpr

A base class for unary operators, e.g. logical NOT.

Parameters:
operator[source]
class BinaryOp(op1, op2, operator)[source]

Bases: WCPSExpr

A base class for binary operators, e.g. logical AND.

Parameters:
operator[source]
class UnaryFunc(op, func)[source]

Bases: WCPSExpr

A base class for unary functions, e.g. Abs.

Parameters:
func[source]
class BinaryFunc(op1, op2, func)[source]

Bases: WCPSExpr

A base class for binary functions, e.g. Pow.

Parameters:
func[source]
class Add(op1, op2)[source]

Bases: BinaryOp

Adds op1 to op2.

Examples:

  • Add(Datacube("test1"), Datacube("test2"))

  • Add(Datacube("test1"), 5)

  • Add(5, Datacube("test1"))

Parameters:
class Sub(op1, op2)[source]

Bases: BinaryOp

Subtracts op2 from op1.

Examples:

  • Sub(Datacube("test1"), Datacube("test2"))

  • Sub(Datacube("test1"), 5)

  • Sub(5, Datacube("test1"))

Parameters:
class Mul(op1, op2)[source]

Bases: BinaryOp

Multiplies op1 by op2.

Examples:

  • Mul(Datacube("test1"), Datacube("test2"))

  • Mul(Datacube("test1"), 5)

  • Mul(5, Datacube("test1"))

Parameters:
class Div(op1, op2)[source]

Bases: BinaryOp

Divides op1 by op2.

Examples:

  • Div(Datacube("test1"), Datacube("test2"))

  • Div(Datacube("test1"), 5)

  • Div(5, Datacube("test1"))

Parameters:
class Mod(op1, op2)[source]

Bases: BinaryFunc

Computes the modulus (remainder of the division) of op1 by op2.

Examples:

  • Mod(Datacube("test1"), Datacube("test2"))

  • Mod(Datacube("test1"), 5)

  • Mod(5, Datacube("test1"))

Parameters:
class Abs(op)[source]

Bases: UnaryFunc

Computes the absolute value of op.

Examples:

  • Abs(Datacube("test1"))

  • Abs(-5)

Parameters:

op (WCPSExpr)

class Round(op)[source]

Bases: UnaryFunc

Rounds op to the nearest integer.

Examples:

  • Round(Datacube("test1"))

  • Round(-5.4)

Parameters:

op (WCPSExpr)

class Floor(op)[source]

Bases: UnaryFunc

Computes the floor of op (rounds down to the nearest integer).

Examples:

  • Floor(Datacube("test1"))

  • Floor(-5.4)

Parameters:

op (WCPSExpr)

class Ceil(op)[source]

Bases: UnaryFunc

Computes the ceiling of op (rounds up to the nearest integer).

Examples:

  • Ceil(Datacube("test1"))

  • Ceil(-5.4)

Parameters:

op (WCPSExpr)

class Exp(op)[source]

Bases: UnaryFunc

Computes the exponential (e^x) of op.

Examples:

  • Exp(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Log(op)[source]

Bases: UnaryFunc

Computes the logarithm (base 10) of op.

Examples:

  • Log(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Ln(op)[source]

Bases: UnaryFunc

Computes the natural logarithm (base e) of op.

Examples:

  • Ln(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Sqrt(op)[source]

Bases: UnaryFunc

Computes the square root of op.

Examples:

  • Sqrt(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Pow(op1, op2)[source]

Bases: BinaryFunc

Raises op1 to the power of op2.

Examples:

  • Pow(Datacube("test1"), Datacube("test2"))

  • Pow(Datacube("test1"), 5)

Parameters:
class Sin(op)[source]

Bases: UnaryFunc

Computes the sine of op.

Examples:

  • Sin(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Cos(op)[source]

Bases: UnaryFunc

Computes the cosine of op.

Examples:

  • Cos(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Tan(op)[source]

Bases: UnaryFunc

Computes the tangent of op.

Examples:

  • Tan(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Sinh(op)[source]

Bases: UnaryFunc

Computes the hyperbolic sine of op.

Examples:

  • Sinh(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Cosh(op)[source]

Bases: UnaryFunc

Computes the hyperbolic cosine of op.

Examples:

  • Cosh(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Tanh(op)[source]

Bases: UnaryFunc

Computes the hyperbolic tangent of op.

Examples:

  • Tanh(Datacube("test1"))

Parameters:

op (WCPSExpr)

class ArcSin(op)[source]

Bases: UnaryFunc

Computes the inverse sine of op.

Examples:

  • ArcSin(Datacube("test1"))

Parameters:

op (WCPSExpr)

class ArcCos(op)[source]

Bases: UnaryFunc

Computes the inverse cosine of op.

Examples:

  • ArcCos(Datacube("test1"))

Parameters:

op (WCPSExpr)

class ArcTan(op)[source]

Bases: UnaryFunc

Computes the inverse tangent of op.

Examples:

  • ArcTan(Datacube("test1"))

Parameters:

op (WCPSExpr)

class ArcTan2(op)[source]

Bases: UnaryFunc

Computes the two-argument inverse tangent of op.

Examples:

  • ArcTan2(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Gt(op1, op2)[source]

Bases: BinaryOp

Checks if op1 is greater than op2.

Examples:

  • Gt(Datacube("test1"), Datacube("test2"))

  • Gt(Datacube("test1"), 10)

Parameters:
class Lt(op1, op2)[source]

Bases: BinaryOp

Checks if op1 is less than op2.

Examples:

  • Lt(Datacube("test1"), Datacube("test2"))

  • Lt(Datacube("test1"), 10)

Parameters:
class Ge(op1, op2)[source]

Bases: BinaryOp

Checks if op1 is greater than or equal to op2.

Examples:

  • Ge(Datacube("test1"), Datacube("test2"))

  • Ge(Datacube("test1"), 10)

Parameters:
class Le(op1, op2)[source]

Bases: BinaryOp

Checks if op1 is less than or equal to op2.

Examples:

  • Le(Datacube("test1"), Datacube("test2"))

  • Le(Datacube("test1"), 10)

Parameters:
class Eq(op1, op2)[source]

Bases: BinaryOp

Checks if op1 is equal to op2.

Examples:

  • Eq(Datacube("test1"), Datacube("test2"))

  • Eq(Datacube("test1"), 10)

Parameters:
class Ne(op1, op2)[source]

Bases: BinaryOp

Checks if op1 is not equal to op2.

Examples:

  • Ne(Datacube("test1"), Datacube("test2"))

  • Ne(Datacube("test1"), 10)

Parameters:
class And(op1, op2)[source]

Bases: BinaryOp

Performs a logical AND operation between op1 and op2.

Examples:

  • And(Datacube("test1"), Datacube("test2"))

  • And(Datacube("test1"), True)

Parameters:
class Or(op1, op2)[source]

Bases: BinaryOp

Performs a logical OR operation between op1 and op2.

Examples:

  • Or(Datacube("test1"), Datacube("test2"))

  • Or(Datacube("test1"), False)

Parameters:
class Xor(op1, op2)[source]

Bases: BinaryOp

Performs a logical XOR operation between op1 and op2.

Examples:

  • Xor(Datacube("test1"), Datacube("test2"))

  • Xor(Datacube("test1"), True)

Parameters:
class Not(op)[source]

Bases: UnaryOp

Performs a logical Not operation on op.

Examples:

  • Not(Datacube("test1"))

  • Not(True)

Parameters:

op (WCPSExpr)

class Overlay(op1, op2)[source]

Bases: BinaryOp

Performs an overlay operation, placing op2 “on top” of op1:

  • wherever the cell value of op2 is not zero and not null, the result value will be this value.

  • wherever the cell value of op2 is zero or null, the cell value of op1 will be taken.

Examples:

  • Overlay(Datacube("test1"), Datacube("test2"))

Parameters:
class Bit(op, pos)[source]

Bases: BinaryFunc

Take the bit in the cell values of op at nonnegative position number pos, and put it as a Boolean value into a byte. Position counting starts with 0 and runs from least to most significant bit.

Parameters:
  • pos (WCPSExpr) – The position at which the bit value should be extracted

  • op (WCPSExpr)

Examples:

  • Bit(Datacube("test1", 5)

class Band(op, field)[source]

Bases: WCPSExpr

Select a field (band, channel) from a multiband operand.

Parameters:
field[source]
class MultiBand(bands)[source]

Bases: WCPSExpr

Create a multiband value. :param bands: a dictionary of (band name, value), e.g. {“red”: cov1, “blue”: 2}

Parameters:

bands (dict)

bands[source]
rgb(r, g, b)[source]

Utility method for conveniently specifying RGB (red, green, blue) multiband values. Examples:

  • rgb(255,255,255)

  • rgb(red_cov, blue_cov, 0)

Parameters:
  • r (OperandType) – red band

  • g (OperandType) – green band

  • b (OperandType) – blue band

Returns:

a MultiBand object with red, green and blue bands correspondingly.

Return type:

MultiBand

rgba(r, g, b, a)[source]

Utility method for conveniently specifying RGBA (red, green, blue, alpha) multiband values. Examples:

  • rgb(255,255,255,255)

  • rgb(red_cov, blue_cov, 0, 255)

Parameters:
  • r (OperandType) – red band

  • g (OperandType) – green band

  • b (OperandType) – blue band

  • a (OperandType) – alpha band

Returns:

a MultiBand object with red, green, blue and alpha bands correspondingly.

Return type:

MultiBand

class Axis(axis_name, low, high=None, crs=None)[source]

Bases: WCPSExpr

Represents an axis interval for defining spatial, temporal, or other dimensional subsets in WCPS queries. An axis subset specifies a trim (or slice) along a specific axis, optionally with a Coordinate Reference System (CRS) if the low/high are not in the native CRS.

This object can be used in operations like subsetting, extending, or scaling coverages. It supports both single values (slicing) and ranges (trimming).

Parameters:
  • axis_name (str) – The name of the axis (e.g., “X”, “Y”, “time”).

  • low (BoundType) – The lower bound of a subset trim, or a slice value if high is not given.

  • high (BoundType) – The upper bound of a subset trim.

  • crs (str) – The CRS associated with the axis (e.g., “EPSG:4326”), usually set if the low/high values are not in the native CRS.

Constants:

MIN (‘*’): Can be used for the minimum bound of an axis. MAX (‘*’): Can be used for the maximum bound of an axis.

Examples:

# Define a spatial axis subset from 15.0 to 20.0 with CRS "EPSG:4326"
axis = Axis("X", 15.0, 20.0, "EPSG:4326")

# Define slicing on the temporal axis time
axis = Axis("time", "2025-01-01")
Raises:

WCPSClientException – If the axis name is empty.

Parameters:
  • axis_name (str)

  • low (BoundType)

  • high (BoundType)

  • crs (str)

MIN = '*'[source]
MAX = '*'[source]
axis_name[source]
low[source]
high = None[source]
crs = None[source]
static get_axis_list(axes)[source]

Normalizes axes into a list of Axis objects. :param axes: may be:

  • a single Axis, e.g. Axis("X", 0, 100.5, "EPSG:4326")

  • a single slice, e.g. "X":1, or "X":1:15.3

  • a tuple of Axis objects, e.g. (Axis(...), Axis(...), ...)

  • a single in-place axis tuple, e.g. ("X", 0, 100.5, "EPSG:4326")

  • a tuple of axis tuples, e.g. (("X", 0, 100.5), (...), ...)

  • a tuple of slices, e.g. ("X":1, "Y":0:100.5)

  • a list of Axis objects, e.g. [Axis(...), Axis(...), ...]

  • a list of axis tuples, e.g. [("X", 0, 100.5), (...), ...]

Raise:

a WCPSClientException in case axes is in invalid shape.

Parameters:

axes (Union[Axis, slice, tuple[Axis], AxisTuple, tuple[AxisTuple], tuple[slice], list[Axis], list[AxisTuple]])

Return type:

list[Axis]

class Subset(op, axes)[source]

Bases: WCPSExpr

Select a spatio-temporal area from a coverage operand.

Parameters:

op (WCPSExpr)

class Extend(op, axes)[source]

Bases: WCPSExpr

Enlarge a coverage with new areas set to null values.

Parameters:

op (WCPSExpr)

class Scale(op)[source]

Bases: WCPSExpr

Resamples the coverage values to fit a new domain. The target domain can be:

  1. An explicit grid domain for each axis with to_explicit_grid_domain():

    Scale(cov).to_explicit_grid_domain(
        [("X", 15, 30), ("Y", 20, 40)])
    
  2. A grid domain matching another coverage with to_grid_domain_of():

    Scale(cov).to_grid_domain_of(cov2)
    
  3. A scale factor equally applied to all axes with by_factor():

    Scale(cov).by_factor(0.5)
    
  1. A scale factor per axis with by_factor_per_axis():

    Scale(cov).by_factor_per_axis([0.5, 2])
    
Parameters:

op (WCPSExpr)

axis_subsets = None[source]
another_coverage = None[source]
scale_factor = None[source]
scale_factors = None[source]
to_explicit_grid_domain(grid_axes)[source]

Scale to fit the grid domain specified by the grid_axes.

Parameters:

grid_axes – a list of Axis

to_grid_domain_of(another_coverage)[source]

Scale to fit the grid domain of another_coverage.

Parameters:

another_coverage (WCPSExpr) – a coverage expression

by_factor(scale_factor)[source]
Parameters:

scale_factor (Union[int, float]) – factor > 1 for scaling up, 0 < factor < 1 for scaling down

by_factor_per_axis(scale_factors)[source]
Parameters:

scale_factors – a list of Axis(name, factor)

class ResampleAlg[source]

Bases: StrEnum

Possible interpolation methods for Reproject.

Initialize self. See help(type(self)) for accurate signature.

NEAR = 'near'[source]
BILINEAR = 'bilinear'[source]
CUBIC = 'cubic'[source]
CUBICSPLINE = 'cubicspline'[source]
LANCZOS = 'lanczos'[source]
AVERAGE = 'average'[source]
MODE = 'mode'[source]
MAX = 'max'[source]
MIN = 'min'[source]
MED = 'med'[source]
Q1 = 'q1'[source]
Q3 = 'q3'[source]
classmethod list()[source]
Returns:

a list of the Enum values.

class Reproject(op, target_crs, interpolation_method=None)[source]

Bases: WCPSExpr

Reproject a coverage to a different CRS.

Parameters:
  • op (WCPSExpr) – the coverage value to be reprojected.

  • target_crs (str) –

    the CRS to which op should be reprojected. It can be in one of these formats:

    • Full CRS URL, e.g. http://localhost:8080/rasdaman/def/crs/EPSG/0/4326 (OGC standard format)

    • Shorthand CRS with authority, version and code, e.g. EPSG/0/4326

    • Shorthand CRS with authority and code, e.g. EPSG:4326

  • interpolation_method (ResampleAlg) – one of the ResampleAlg constants, e.g. ResampleAlg.BILINEAR.

target_crs: str[source]
interpolation_method = None[source]
axis_resolutions: list[Axis] | None = None[source]
axis_subsets: list[Axis] | None = None[source]
subset_domain: WCPSExpr | None = None[source]
to_axis_resolutions(axis_resolutions)[source]

The reprojected result will be resampled to these resolutions.

Parameters:

axis_resolutions – a list of Axis objects with only the axis name and low bound (corresponding to a resolution) specified.

Raise:

WCPSClientException if an axis object has the Axis.high or Axis.crs set.

Return type:

Reproject

Example:

cov1 = Datacube("cov1")
Reproject(cov1, "EPSG:4326", ResampleAlg.AVERAGE)
    .to_axis_resolutions([("X", 1.5), ("Y", 2)])
subset_by_axes(axis_subsets)[source]

The reprojected result will be cropped to the specified axis subsets.

Parameters:

axis_subsets – a list of Axis objects.

Raise:

WCPSClientException if an axis object does not have the Axis.high set, or it has the Axis.crs set.

Return type:

Reproject

Example:

cov1 = Datacube("cov1")
Reproject(cov1, "EPSG:4326")
    .subset_by_axes([("X", 1.5, 2.5), ("Y", 2, 4)])
subset_by_coverage_domain(subset_domain)[source]

The reprojected result will be cropped to the domain of a coverage expression subset_domain.

Parameters:

subset_domain – a coverage expression

Return type:

Reproject

Example:

cov1 = Datacube("cov1")
cov2 = Datacube("cov2")
Reproject(cov1, "EPSG:4326")
    .subset_by_coverage_domain(cov2)
class CastType[source]

Bases: StrEnum

Possible cell types to which a value can be casted.

Initialize self. See help(type(self)) for accurate signature.

BOOLEAN = 'boolean'[source]
CHAR = 'char'[source]
UNSIGNED_CHAR = 'unsigned char'[source]
SHORT = 'short'[source]
UNSIGNED_SHORT = 'unsigned short'[source]
INT = 'int'[source]
UNSIGNED_INT = 'unsigned int'[source]
LONG = 'long'[source]
UNSIGNED_LONG = 'unsigned long'[source]
FLOAT = 'float'[source]
DOUBLE = 'double'[source]
CINT16 = 'cint16'[source]
CINT32 = 'cint32'[source]
COMPLEX = 'complex'[source]
COMPLEX2 = 'complex2'[source]
classmethod list()[source]
Returns:

a list of the Enum values.

class Cast(op, target_type=None)[source]

Bases: WCPSExpr

Cast a value to a new type. The type can be specified with the to() method.

Parameters:

Examples:

  • Cast(Datacube("test"), CastType.CHAR)

target_type = None[source]
to(target_type)[source]

Specify the type to which to cast this operand. :param target_type: must be one of the CastType constants, e.g. CastType.CHAR.

Parameters:

target_type (Union[CastType, str])

Return type:

Cast

class Sum(op)[source]

Bases: UnaryFunc

Computes the sum of the cell values of the operand op.

Examples:

  • Sum(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Count(op)[source]

Bases: UnaryFunc

Counts the number of true values in the boolean operand op.

Examples:

  • Count(Datacube("test1") > 5)

Parameters:

op (WCPSExpr)

class Avg(op)[source]

Bases: UnaryFunc

Computes the average (mean) of the cell values of the operand op.

Examples:

  • Avg(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Min(op)[source]

Bases: UnaryFunc

Returns the minimum value among the elements of the operand op.

Examples:

  • Min(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Max(op)[source]

Bases: UnaryFunc

Returns the maximum value among the elements of the operand op.

Examples:

  • Max(Datacube("test1"))

Parameters:

op (WCPSExpr)

class All(op)[source]

Bases: UnaryFunc

Returns true if all elements in the operand op are true.

Examples:

  • All(Datacube("test1"))

Parameters:

op (WCPSExpr)

class Some(op)[source]

Bases: UnaryFunc

Returns true if some elements in the operand op are true.

Examples:

  • Some(Datacube("test1"))

Parameters:

op (WCPSExpr)

class AxisIter(var_name, axis_name)[source]

Bases: WCPSExpr

An axis iterator expression set in a Condense.over() or a Coverage.over() methods. The iteration can be over an integer grid interval(), of_grid_axis() domain of a particular coverage, or of_of_geo_axis() domain of a coverage.

The ref() method should be used to get a reference to an AxisIter that can be used in expressions for the Condense.where(), Condense.using(), or Coverage.values() clauses.

Parameters:
  • var_name (str) – unique iterator variable name.

  • axis_name (str) – an axis over which it iterates.

Examples:

  • AxisIter('$x', 'X').interval(0, 100) - iterate from 0 to 100, inclusive

  • AxisIter('$pt', 'time').of_grid_axis(Datacube("timeseries"))

  • AxisIter('$plat', 'Lat').of_geo_axis(Datacube("cov"))

var_name[source]

unique iterator variable name

axis_name[source]

an axis over which it iterates

low = None[source]

optional lower iteration bound

high = None[source]

optional upper iteration bound

grid_axis = None[source]

iterator over a grid axis domain of a coverage

geo_axis = None[source]

iterator over a geo axis domain of a coverage

interval(low, high)[source]

Iterate in the [low, high] interval.

Parameters:
  • low (BoundType)

  • high (BoundType)

of_grid_axis(cov_expr)[source]

Iterate over the grid axis domain of a coverage cov_expr.

Parameters:

cov_expr (WCPSExpr)

of_geo_axis(cov_expr)[source]

Iterate over the geo axis domain of a coverage cov_expr.

Parameters:

cov_expr (WCPSExpr)

ref()[source]
Returns:

a reference object that can be used in expressions set in the Condense.where(), Condense.using(), or Coverage.values() methods.

Return type:

AxisIterRef

class AxisIterRef(axis_iter)[source]

Bases: WCPSExpr

Reference to an AxisIter object, to be used in expressions set in the

Condense.where(), Condense.using(), or Coverage.values() methods.

Parameters:

axis_iter (AxisIter)

iter_var[source]
class CondenseOp[source]

Bases: StrEnum

Possible general Condense operators.

Initialize self. See help(type(self)) for accurate signature.

PLUS = '+'[source]
MULTIPLY = '*'[source]
MIN = 'min'[source]
MAX = 'max'[source]
AND = 'and'[source]
OR = 'or'[source]
OVERLAY = 'overlay'[source]
classmethod list()[source]
Returns:

a list of the Enum values.

class Condense(condense_op, over=None, using=None, where=None)[source]

Bases: WCPSExpr

A general coverage condense (aggregation) operation. It aggregates values over() an iteration domain formed of a list of AxisIter, with a condenser operation (one of +, *, max, min, and, or or). For each coordinate in the iteration domain defined by the over clause, the using() expression is evaluated and added to the final aggregated result; the optional where() expression allows to filter values from the aggregation.

It corresponds to a WCPS expression of the following form:

condense op
over $iterVar axis(lo:hi), ...
[ where boolScalarExpr ]
using scalarExpr

Typically, the iterator variable iterates through a grid domain (AxisIter.interval() or AxisIter.of_grid_axis()). However, iteration over a geo domain is also supported with AxisIter.of_geo_axis().

Parameters:

For example, to sum the values of a coverage mycov (same as using the Sum shorthand):

cov = Datacube("mycov")
pt_var = AxisIter('$pt', 'time').of_grid_axis(cov)
pt_ref = pt_var.ref()
Condense(CondenseOp.PLUS)
    .over(pt_var)
    .using(cov1[('time', pt_ref)])
condense_op[source]

One of the CondenseOp constants, e.g. CondenseOp.PLUS

iter_vars = [][source]

A list of AxisIter forming the iteration domain for aggregation.

using_clause = None[source]
where_clause = None[source]
over(iter_var)[source]

Add an iterator variable to a Condense or a Coverage operand. Calling this method on another object type will raise a WCPSClientException.

Parameters:

iter_var (Union[AxisIter, list[AxisIter]]) – an iterator variable

Returns:

the same object with the iter_var appended to its iterator variables list

Return type:

Condense

Examples:

cov = Datacube("testcube")
pt_var = AxisIter('$pt', 'time').of_grid_axis(cov)
px_var = AxisIter('$px', 'X').interval(0, 100)
cov.condense(CondenseOp.PLUS).over(pt_var).over(px_var)
using(using)[source]

Specify an aggregation expression, evaluated for each point in the over() domain and aggregated into the final result with the condense_op.

Parameters:

using (OperandType)

Return type:

Condense

where(where)[source]

Specify a filtering expression, evaluated for each point in the over() domain. If its result is false at that point then the using() expression is not executed.

Parameters:

where (OperandType)

Return type:

Condense

class Coverage(name, over=None, values_clause=None, value_list_clause=None)[source]

Bases: WCPSExpr

A general coverage constructor operation. It allows to create a coverage over() a spatio-temporal domain, where for each coordinate in the domain the value is dynamically calculated from a values() expression which potentially references the iterator variables set in the over() method. It corresponds to a WCPS expression of the following form:

coverage covName
over $iterVar axis(lo:hi), ...
values scalarExpr

Typically, the iterator variable iterates through a grid domain (AxisIter.interval() or AxisIter.of_grid_axis()). However, iteration over a geo domain is also supported with AxisIter.of_geo_axis().

Parameters:
  • name (str) – a name for the new coverage

  • over (list) – a list of axis iterators

  • values_clause (OperandType) – an expression evaluating to a value for each point in the over domain; exclusive with value_list_clause.

  • value_list_clause (list[ScalarType]) – a list enumerating all cell values in the coverage domain; exclusive with values_clause.

For example, to create a 2D geo-referenced coverage with Lat and Lon axes, based on an existing geo-referenced coverage mycov:

cov = Datacube("mycov")
plat_var = AxisIter('$pLat', 'Lat')
                .of_geo_axis(cov['Lat', -30, -28.5])
plon_var = AxisIter('$pLon', 'Lon')
                .of_geo_axis(cov['Lon', 111.975, 113.475])
Coverage("copy_of_mycov")
    .over(plat_var).over(plon_var)
    .values(cov1[('Lat', plat_var.ref()),
                 ('Lon', plon_var.ref())]))
name[source]

Name of the created coverage (datacube).

iter_vars = None[source]

A list of AxisIter forming the created coverage domain.

values_clause = None[source]

An expression evaluated for each point in the coverage domain.

value_list_clause = None[source]

A list enumerating all cell values in the coverage domain.

over(iter_var)[source]

Add an iterator variable to the coverage constructor.

Parameters:

iter_var (Union[AxisIter, list[AxisIter]]) – an iterator variable or a list of iterator variables

Returns:

the same object with the iter_var appended to its iterator variables list

Return type:

Coverage

Examples:

cov = Datacube("testcube")
pt_var = AxisIter('$pt', 'time').of_grid_axis(cov)
px_var = AxisIter('$px', 'X').interval(0, 100)
cov.condense(CondenseOp.PLUS).over(pt_var).over(px_var)
values(values_clause)[source]

Specify a VALUES expression, evaluated for each point in the over() domain.

Parameters:

values_clause (OperandType)

Return type:

Coverage

value_list(value_list_clause)[source]

Specify a VALUE LIST expression, enumerating all values in the over() domain.

Parameters:

value_list_clause (list[ScalarType])

Return type:

Coverage

class Switch[source]

Bases: WCPSExpr

Perform a switch operation for conditional evaluation. This produces a WCPS query fragment of the format:

switch
case boolCovExpr return covExpr
case boolCovExpr return covExpr
...
default return covExpr

Use pairs of case() and then() method calls to specify case/return branches. Finally make a default() method call to specify a default case executed when none of the case conditions are satisfied.

Examples:

cov1 = Datacube("cube1")
cov2 = Datacube("cube2")
Switch().case(cov1 > 5).then(cov2).default(cov1)
case_expr: list[WCPSExpr] = [][source]
then_expr: list[WCPSExpr] = [][source]
default_expr = None[source]
case(case_expr)[source]

Specify a condition expression. :param case_expr: the boolean case expression. :raise: WCPSClientException if there is a mismatch between the number of case/then expressions.

Parameters:

case_expr (WCPSExpr)

Return type:

Switch

then(then_expr)[source]

Specify an expression to be evaluated when the previously set case expression is true.

Parameters:

then_expr (WCPSExpr) – the then expression.

Raise:

WCPSClientException if there is a mismatch between the number of case/then expressions.

Return type:

Switch

default(default_expr)[source]

Specify a default expressions executed when none of the case conditions are satisfied.

Parameters:

default_expr (WCPSExpr) – the default expression.

Raise:

WCPSClientException if no case expressions have been specified, or if a default expression has already been set.

Return type:

Switch

class Clip(op, wkt)[source]

Bases: WCPSExpr

Clip op with the given WKT string. For supported WKT parameters see https://doc.rasdaman.org/05_geo-services-guide.html#polygon-raster-clipping

Examples:

c = Datacube("cov")
Clip(c, "POLYGON((13589894.568 -2015496.69612, 15086830.0246 -1780682.3822))")

Clip(c, 'LineString("2008-01-01T02:01:20.000Z" 75042.7273594 5094865.55794,
                    "2008-01-08T00:02:58.000Z" 705042.727359 5454865.55794)')

Clip(c, "Multipolygon( ((-23.189600 118.432617, -27.458321 117.421875,
                         -30.020354 126.562500, -24.295789 125.244141)),
                       ((-27.380304 137.768555, -30.967012 147.700195,
                         -25.491629 151.259766, -18.050561 142.075195)) )")

Clip(c, "CURTAIN(projection(Lat, Long),
                 Polygon((25 40, 30 40, 30 45, 30 42)) )")

Clip(c, 'CORRIDOR(projection(E, N),
                  LineString("2008-01-01T02:01:20.000Z" 75042.7273594  5094865.55794,
                             "2008-01-01T02:01:20.000Z" 75042.7273594 5194865.55794),
                  LineString(75042.7273594 5094865.55794, 75042.7273594 5094865.55794,
                             85042.7273594 5194865.55794, 95042.7273594 5194865.55794) )')

Clip(c, 'CORRIDOR(projection(Lat, Long),
                  LineString(26 41 "1950-01-01", 28 41 "1950-01-02"),
                  Polygon((25 40, 30 40, 30 45, 25 45)), discrete)')
Parameters:
  • op (WCPSExpr) – coverage expression to clip

  • wkt (str) – a WKT string describing the geometry for clipping

VALID_GEOMETRIES = ['LineString', 'Polygon', 'MultiLineString', 'MultiPolygon', 'Curtain', 'Corridor'][source]
wkt = ''[source]
class Udf(function_name, operands)[source]

Bases: WCPSExpr

Execute a user-defined function (UDF), or any other WCPS function for which no concrete class exists yet.

Parameters:
  • function_name (str) – the UDF name, e.g. image.stretch

  • operands (list[OperandType]) – a list of operands that the UDF expects

Examples:

stretch = Udf('stretch', Datacube('cov1'))
function_name[source]
class Encode(op, data_format=None, format_params=None)[source]

Bases: WCPSExpr

Encode a coverage to some data format. The data format must be specified with the to() method if it isn’t provided here. Format parameters can be specified with the params() method.

Parameters:
  • op (WCPSExpr) – the coverage expression to encode.

  • data_format (str) – the data format, e.g. “GTiff”

  • format_params (str) – additional format parameters the influence the encoding

Examples:

  • Encode(Datacube("test")).to("GTiff")

  • Encode(Datacube("test"), "GTiff")

  • Encode(Datacube("test"), "GTiff", "...")

data_format = None[source]
format_params = None[source]
to(data_format)[source]

Set the encoding data format.

Parameters:

data_format (str) – the data format, e.g. “GTiff”

Return type:

Encode

params(format_params)[source]

Set the encoding format parameters.

Parameters:

format_params (str) – additional format parameters the influence the encoding

Return type:

Encode

exception WCPSClientException[source]

Bases: Exception

An exception thrown by this library.

Initialize self. See help(type(self)) for accurate signature.