Skip to content

processing_graph_builder.operators

This module contains helpers to create processing graph operators for the Geo Engine API.

class Operator()

Base class for all operators.

@abstractmethod
def name() -> str

Returns the name of the operator.

@abstractmethod
def to_dict() -> dict[str, Any]

Returns a dictionary representation of the operator that can be used to create a JSON request for the API.

@abstractmethod
def data_type() -> Literal["Raster", "Vector"]

Returns the type of the operator.

def to_processing_graph_dict() -> dict[str, Any]

Returns a dictionary representation of a processing graph that calls the operator" "that can be used to create a JSON request for the processing graph API.

@deprecated("Use `Operator.to_processing_graph_dict` instead.",
category=DeprecationWarning)
def to_workflow_dict() -> dict[str, Any]

Deprecated: use Operator.to_processing_graph_dict instead.

@classmethod
def from_processing_graph_dict(cls, processing_graph) -> Operator

Returns an operator from a processing graph dictionary.

@classmethod
@deprecated("Use `Operator.from_processing_graph_dict` instead.",
category=DeprecationWarning)
def from_workflow_dict(cls, workflow) -> Operator

Deprecated: use Operator.from_processing_graph_dict instead.

class RasterOperator(Operator)

Base class for all raster operators.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> RasterOperator

Returns an operator from a dictionary.

class VectorOperator(Operator)

Base class for all vector operators.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> VectorOperator

Returns an operator from a dictionary.

class GdalSource(RasterOperator)

A GDAL source operator.

def __init__(dataset: str | DatasetName)

Creates a new GDAL source operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> GdalSource

Returns an operator from a dictionary.

class MultiBandGdalSource(RasterOperator)

A multi-band GDAL source operator referencing a named dataset with all its bands.

def __init__(dataset: str | DatasetName)

Creates a new multi-band GDAL source operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str,
Any]) -> MultiBandGdalSource

Returns an operator from a dictionary.

class OgrSource(VectorOperator)

An OGR source operator.

def __init__(dataset: str | DatasetName,
attribute_projection: str | None = None,
attribute_filters: str | None = None)

Creates a new OGR source operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> OgrSource

Returns an operator from a dictionary.

class Interpolation(RasterOperator)

An interpolation operator.

def __init__(source_operator: RasterOperator,
output_x: float,
output_y: float,
output_method: Literal["resolution", "fraction"] = "resolution",
interpolation: Literal["biLinear",
"nearestNeighbor"] = "biLinear",
output_origin_reference: tuple[float, float] | None = None)

Creates a new interpolation operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> Interpolation

Returns an operator from a dictionary.

class Downsampling(RasterOperator)

A Downsampling operator.

def __init__(source_operator: RasterOperator,
output_x: float,
output_y: float,
output_method: Literal["resolution", "fraction"] = "resolution",
sample_method: Literal["nearestNeighbor"] = "nearestNeighbor",
output_origin_reference: tuple[float, float] | None = None)

Creates a new Downsampling operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> Downsampling

Returns an operator from a dictionary.

class ColumnNames()

Base class for deriving column names from bands of a raster.

@classmethod
def from_dict(cls, rename_dict: dict[str, Any]) -> ColumnNames

Returns a ColumnNames object from a dictionary.

class ColumnNamesDefault(ColumnNames)

column names with default suffix.

class ColumnNamesSuffix(ColumnNames)

Rename bands with custom suffixes.

class ColumnNamesNames(ColumnNames)

Rename bands with new names.

class RasterVectorJoin(VectorOperator)

A RasterVectorJoin operator.

def __init__(raster_sources: list[RasterOperator],
vector_source: VectorOperator,
names: ColumnNames,
temporal_aggregation: Literal["none", "first", "mean"] = "none",
temporal_aggregation_ignore_nodata: bool = False,
feature_aggregation: Literal["first", "mean"] = "mean",
feature_aggregation_ignore_nodata: bool = False)

Creates a new RasterVectorJoin operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> RasterVectorJoin

Returns an operator from a dictionary.

class PointInPolygonFilter(VectorOperator)

A PointInPolygonFilter operator.

def __init__(point_source: VectorOperator, polygon_source: VectorOperator)

Creates a new PointInPolygonFilter filter operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str,
Any]) -> PointInPolygonFilter

Returns an operator from a dictionary.

class RasterScaling(RasterOperator)

A RasterScaling operator.

This operator scales the values of a raster by a given slope and offset.

The scaling is done as follows: y = (x - offset) / slope

The unscale mode is the inverse of the scale mode: x = y * slope + offset

def __init__(source: RasterOperator,
slope: float | str | None = None,
offset: float | str | None = None,
scaling_mode: Literal["mulSlopeAddOffset",
"subOffsetDivSlope"] = "mulSlopeAddOffset",
output_measurement: str | None = None)

Creates a new RasterScaling operator.

class RasterTypeConversion(RasterOperator)

A RasterTypeConversion operator.

def __init__(source: RasterOperator,
output_data_type: Literal["U8", "U16", "U32", "U64", "I8", "I16",
"I32", "I64", "F32", "F64"])

Creates a new RasterTypeConversion operator.

class Reprojection(Operator)

A Reprojection operator.

def __init__(source: Operator, target_spatial_reference: str)

Creates a new Reprojection operator.

def as_vector() -> VectorOperator

Casts this operator to a VectorOperator.

def as_raster() -> RasterOperator

Casts this operator to a RasterOperator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> Reprojection

Constructs the operator from the given dictionary.

class Expression(RasterOperator)

An Expression operator that computes a pixel-wise expression on the bands of a raster.

The expression refers to the bands by their names, e.g., (nir - red) / (nir + red). Characters in band names that are not letters or digits are replaced by underscores, e.g., nir 1 becomes nir_1. Rename bands with the RasterStacker operator to refer to them by other names.

Referring to the bands as A, B, C, … is deprecated.

def __init__(expression: str,
source: RasterOperator,
output_type: Literal["U8", "U16", "U32", "U64", "I8", "I16",
"I32", "I64", "F32", "F64"] = "F32",
map_no_data: bool = False,
output_band: RasterBandDescriptor | None = None)

Creates a new Expression operator.

class BandwiseExpression(RasterOperator)

A bandwise Expression operator.

def __init__(expression: str,
source: RasterOperator,
output_type: Literal["U8", "U16", "U32", "U64", "I8", "I16",
"I32", "I64", "F32", "F64"] = "F32",
map_no_data: bool = False)

Creates a new Expression operator.

class GeoVectorDataType(Enum)

The output type of geometry vector data.

class VectorExpression(VectorOperator)

The VectorExpression operator.

def __init__(source: VectorOperator,
*,
expression: str,
input_columns: list[str],
output_column: str | GeoVectorDataType,
geometry_column_name: str | None = None,
output_measurement: Measurement | None = None)

Creates a new VectorExpression operator.

class TemporalRasterAggregation(RasterOperator)

A TemporalRasterAggregation operator.

def __init__(source: RasterOperator,
aggregation_type: Literal["mean", "min", "max", "median", "count",
"sum", "first", "last",
"percentileEstimate"],
ignore_no_data: bool = False,
granularity: Literal["days", "months", "years", "hours",
"minutes", "seconds", "millis"] = "days",
window_size: int = 1,
output_type: Literal["U8", "U16", "U32", "U64", "I8", "I16",
"I32", "I64", "F32", "F64"] | None = None,
percentile: float | None = None,
window_reference: datetime.datetime | np.datetime64
| None = None)

Creates a new TemporalRasterAggregation operator.

class TimeShift(Operator)

A RasterTypeConversion operator.

def __init__(source: RasterOperator | VectorOperator,
shift_type: Literal["relative", "absolute"],
granularity: Literal["days", "months", "years", "hours",
"minutes", "seconds", "millis"], value: int)

Creates a new RasterTypeConversion operator.

def as_vector() -> VectorOperator

Casts this operator to a VectorOperator.

def as_raster() -> RasterOperator

Casts this operator to a RasterOperator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> TimeShift

Constructs the operator from the given dictionary.

class RenameBands()

Base class for renaming bands of a raster.

@classmethod
def from_dict(cls, rename_dict: dict[str, Any]) -> RenameBands

Returns a RenameBands object from a dictionary.

class RenameBandsDefault(RenameBands)

Rename bands with default suffix.

class RenameBandsSuffix(RenameBands)

Rename bands with custom suffixes.

class RenameBandsRename(RenameBands)

Rename bands with new names.

class RasterStacker(RasterOperator)

The RasterStacker operator.

def __init__(sources: list[RasterOperator], rename: RenameBands | None = None)

Creates a new RasterStacker operator.

class BandFilter(RasterOperator)

The BandFilter operator.

Selects a subset of the source's bands, either by band names or by band indices. The order of the remaining bands is preserved and the output bands are renumbered to 0..n.

def __init__(source: RasterOperator, bands: list[str] | list[int])

Creates a new BandFilter operator.

@classmethod
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> BandFilter

Returns an operator from a dictionary.

class BandNeighborhoodAggregate(RasterOperator)

The BandNeighborhoodAggregate operator.

def __init__(source: RasterOperator,
aggregate: BandNeighborhoodAggregateParams)

Creates a new BandNeighborhoodAggregate operator.

class BandNeighborhoodAggregateParams()

Abstract base class for band neighborhood aggregate params.

@classmethod
def from_dict(
cls, band_neighborhood_aggregate_dict: dict[str, Any]
) -> BandNeighborhoodAggregateParams

Returns a BandNeighborhoodAggregate object from a dictionary.

BandNeighborhoodAggregateFirstDerivative Objects

Section titled “BandNeighborhoodAggregateFirstDerivative Objects”
@dataclass
class BandNeighborhoodAggregateFirstDerivative(BandNeighborhoodAggregateParams
)

The first derivative band neighborhood aggregate.

@dataclass
class BandNeighborhoodAggregateAverage(BandNeighborhoodAggregateParams)

The average band neighborhood aggregate.

class Onnx(RasterOperator)

Onnx ML operator.

def __init__(source: RasterOperator, model: str)

Creates a new Onnx operator.

class PolygonRasterizationValue()

The value that a polygon burns into the pixels it covers.

@classmethod
def from_dict(cls, value_dict: dict[str, Any]) -> PolygonRasterizationValue

Returns a value object from a dictionary.

@classmethod
def constant(cls, value: float) -> PolygonRasterizationValue

Each covered pixel gets the value.

@classmethod
def count(cls) -> PolygonRasterizationValue

Each pixel gets the number of polygons that cover it.

@classmethod
def attribute(cls,
column: str,
aggregation: PolygonRasterizationAggregation,
ignore_no_data: bool = True) -> PolygonRasterizationValue

Each pixel gets the value of a numeric column, aggregated over all polygons that cover it.

If ignore_no_data is False, features with a null value make all pixels they cover no data.

@dataclass
class PolygonRasterizationValueConstant(PolygonRasterizationValue)

Each covered pixel gets the constant value.

@dataclass
class PolygonRasterizationValueCount(PolygonRasterizationValue)

Each pixel gets the number of polygons that cover it.

PolygonRasterizationValueAttribute Objects

Section titled “PolygonRasterizationValueAttribute Objects”
@dataclass
class PolygonRasterizationValueAttribute(PolygonRasterizationValue)

Each pixel gets the value of a numeric column, aggregated over all polygons that cover it.

class PolygonRasterizationTime()

How the time slices of the output raster are derived from the features.

@classmethod
def from_dict(cls, time_dict: dict[str, Any]) -> PolygonRasterizationTime

Returns a time object from a dictionary.

@classmethod
def feature_times(cls) -> PolygonRasterizationTime

Every start and end time of a feature is a slice boundary.

@classmethod
def regular(
cls,
granularity: TimeGranularity,
step: int = 1,
reference: datetime.datetime | np.datetime64 | None = None
) -> PolygonRasterizationTime

Regular time slices of length step, aligned to reference (default: Unix epoch).

@classmethod
def all_features(cls) -> PolygonRasterizationTime

All features, regardless of their times, are rasterized into one time slice that is valid forever.

PolygonRasterizationTimeFeatureTimes Objects

Section titled “PolygonRasterizationTimeFeatureTimes Objects”
@dataclass
class PolygonRasterizationTimeFeatureTimes(PolygonRasterizationTime)

Every start and end time of a feature is a slice boundary.

@dataclass
class PolygonRasterizationTimeRegular(PolygonRasterizationTime)

Regular time slices that contain all features whose time intersects them.

PolygonRasterizationTimeAllFeatures Objects

Section titled “PolygonRasterizationTimeAllFeatures Objects”
@dataclass
class PolygonRasterizationTimeAllFeatures(PolygonRasterizationTime)

All features, regardless of their times, are rasterized into one time slice that is valid forever.

class PolygonRasterization(RasterOperator)

The PolygonRasterization operator, which rasterizes (multi) polygons.

A pixel is covered by a polygon if its center lies inside the polygon. Pixels that are not covered by any polygon are no data.

def __init__(source: VectorOperator,
*,
spatial_resolution: tuple[float, float],
origin_coordinate: tuple[float, float] | None = None,
value: PolygonRasterizationValue | None = None,
output_type: Literal["U8", "U16", "U32", "U64", "I8", "I16",
"I32", "I64", "F32", "F64"] | None = None,
output_measurement: Measurement | None = None,
time: PolygonRasterizationTime | None = None)

Creates a new PolygonRasterization operator.

spatial_resolution are the positive pixel sizes in x and y direction. The rows of the grid run from north to south, and origin_coordinate is a pixel corner to which the grid is aligned (default: (0, 0)). Omitted parameters use the defaults of the server, i.e., a constant value of 1 and time slices between the start and end times of the features.