processing_graph_builder.operators
This module contains helpers to create processing graph operators for the Geo Engine API.
Operator Objects
Section titled “Operator Objects”class Operator()Base class for all operators.
@abstractmethoddef name() -> strReturns the name of the operator.
to_dict
Section titled “to_dict”@abstractmethoddef to_dict() -> dict[str, Any]Returns a dictionary representation of the operator that can be used to create a JSON request for the API.
data_type
Section titled “data_type”@abstractmethoddef data_type() -> Literal["Raster", "Vector"]Returns the type of the operator.
to_processing_graph_dict
Section titled “to_processing_graph_dict”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.
to_workflow_dict
Section titled “to_workflow_dict”@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.
from_processing_graph_dict
Section titled “from_processing_graph_dict”@classmethoddef from_processing_graph_dict(cls, processing_graph) -> OperatorReturns an operator from a processing graph dictionary.
from_workflow_dict
Section titled “from_workflow_dict”@classmethod@deprecated("Use `Operator.from_processing_graph_dict` instead.", category=DeprecationWarning)def from_workflow_dict(cls, workflow) -> OperatorDeprecated: use Operator.from_processing_graph_dict instead.
RasterOperator Objects
Section titled “RasterOperator Objects”class RasterOperator(Operator)Base class for all raster operators.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> RasterOperatorReturns an operator from a dictionary.
VectorOperator Objects
Section titled “VectorOperator Objects”class VectorOperator(Operator)Base class for all vector operators.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> VectorOperatorReturns an operator from a dictionary.
GdalSource Objects
Section titled “GdalSource Objects”class GdalSource(RasterOperator)A GDAL source operator.
__init__
Section titled “__init__”def __init__(dataset: str | DatasetName)Creates a new GDAL source operator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> GdalSourceReturns an operator from a dictionary.
MultiBandGdalSource Objects
Section titled “MultiBandGdalSource Objects”class MultiBandGdalSource(RasterOperator)A multi-band GDAL source operator referencing a named dataset with all its bands.
__init__
Section titled “__init__”def __init__(dataset: str | DatasetName)Creates a new multi-band GDAL source operator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> MultiBandGdalSourceReturns an operator from a dictionary.
OgrSource Objects
Section titled “OgrSource Objects”class OgrSource(VectorOperator)An OGR source operator.
__init__
Section titled “__init__”def __init__(dataset: str | DatasetName, attribute_projection: str | None = None, attribute_filters: str | None = None)Creates a new OGR source operator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> OgrSourceReturns an operator from a dictionary.
Interpolation Objects
Section titled “Interpolation Objects”class Interpolation(RasterOperator)An interpolation operator.
__init__
Section titled “__init__”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.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> InterpolationReturns an operator from a dictionary.
Downsampling Objects
Section titled “Downsampling Objects”class Downsampling(RasterOperator)A Downsampling operator.
__init__
Section titled “__init__”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.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> DownsamplingReturns an operator from a dictionary.
ColumnNames Objects
Section titled “ColumnNames Objects”class ColumnNames()Base class for deriving column names from bands of a raster.
from_dict
Section titled “from_dict”@classmethoddef from_dict(cls, rename_dict: dict[str, Any]) -> ColumnNamesReturns a ColumnNames object from a dictionary.
ColumnNamesDefault Objects
Section titled “ColumnNamesDefault Objects”class ColumnNamesDefault(ColumnNames)column names with default suffix.
ColumnNamesSuffix Objects
Section titled “ColumnNamesSuffix Objects”class ColumnNamesSuffix(ColumnNames)Rename bands with custom suffixes.
ColumnNamesNames Objects
Section titled “ColumnNamesNames Objects”class ColumnNamesNames(ColumnNames)Rename bands with new names.
RasterVectorJoin Objects
Section titled “RasterVectorJoin Objects”class RasterVectorJoin(VectorOperator)A RasterVectorJoin operator.
__init__
Section titled “__init__”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.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> RasterVectorJoinReturns an operator from a dictionary.
PointInPolygonFilter Objects
Section titled “PointInPolygonFilter Objects”class PointInPolygonFilter(VectorOperator)A PointInPolygonFilter operator.
__init__
Section titled “__init__”def __init__(point_source: VectorOperator, polygon_source: VectorOperator)Creates a new PointInPolygonFilter filter operator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> PointInPolygonFilterReturns an operator from a dictionary.
RasterScaling Objects
Section titled “RasterScaling Objects”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
__init__
Section titled “__init__”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.
RasterTypeConversion Objects
Section titled “RasterTypeConversion Objects”class RasterTypeConversion(RasterOperator)A RasterTypeConversion operator.
__init__
Section titled “__init__”def __init__(source: RasterOperator, output_data_type: Literal["U8", "U16", "U32", "U64", "I8", "I16", "I32", "I64", "F32", "F64"])Creates a new RasterTypeConversion operator.
Reprojection Objects
Section titled “Reprojection Objects”class Reprojection(Operator)A Reprojection operator.
__init__
Section titled “__init__”def __init__(source: Operator, target_spatial_reference: str)Creates a new Reprojection operator.
as_vector
Section titled “as_vector”def as_vector() -> VectorOperatorCasts this operator to a VectorOperator.
as_raster
Section titled “as_raster”def as_raster() -> RasterOperatorCasts this operator to a RasterOperator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> ReprojectionConstructs the operator from the given dictionary.
Expression Objects
Section titled “Expression Objects”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.
__init__
Section titled “__init__”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.
BandwiseExpression Objects
Section titled “BandwiseExpression Objects”class BandwiseExpression(RasterOperator)A bandwise Expression operator.
__init__
Section titled “__init__”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.
GeoVectorDataType Objects
Section titled “GeoVectorDataType Objects”class GeoVectorDataType(Enum)The output type of geometry vector data.
VectorExpression Objects
Section titled “VectorExpression Objects”class VectorExpression(VectorOperator)The VectorExpression operator.
__init__
Section titled “__init__”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.
TemporalRasterAggregation Objects
Section titled “TemporalRasterAggregation Objects”class TemporalRasterAggregation(RasterOperator)A TemporalRasterAggregation operator.
__init__
Section titled “__init__”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.
TimeShift Objects
Section titled “TimeShift Objects”class TimeShift(Operator)A RasterTypeConversion operator.
__init__
Section titled “__init__”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.
as_vector
Section titled “as_vector”def as_vector() -> VectorOperatorCasts this operator to a VectorOperator.
as_raster
Section titled “as_raster”def as_raster() -> RasterOperatorCasts this operator to a RasterOperator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> TimeShiftConstructs the operator from the given dictionary.
RenameBands Objects
Section titled “RenameBands Objects”class RenameBands()Base class for renaming bands of a raster.
from_dict
Section titled “from_dict”@classmethoddef from_dict(cls, rename_dict: dict[str, Any]) -> RenameBandsReturns a RenameBands object from a dictionary.
RenameBandsDefault Objects
Section titled “RenameBandsDefault Objects”class RenameBandsDefault(RenameBands)Rename bands with default suffix.
RenameBandsSuffix Objects
Section titled “RenameBandsSuffix Objects”class RenameBandsSuffix(RenameBands)Rename bands with custom suffixes.
RenameBandsRename Objects
Section titled “RenameBandsRename Objects”class RenameBandsRename(RenameBands)Rename bands with new names.
RasterStacker Objects
Section titled “RasterStacker Objects”class RasterStacker(RasterOperator)The RasterStacker operator.
__init__
Section titled “__init__”def __init__(sources: list[RasterOperator], rename: RenameBands | None = None)Creates a new RasterStacker operator.
BandFilter Objects
Section titled “BandFilter Objects”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.
__init__
Section titled “__init__”def __init__(source: RasterOperator, bands: list[str] | list[int])Creates a new BandFilter operator.
from_operator_dict
Section titled “from_operator_dict”@classmethoddef from_operator_dict(cls, operator_dict: dict[str, Any]) -> BandFilterReturns an operator from a dictionary.
BandNeighborhoodAggregate Objects
Section titled “BandNeighborhoodAggregate Objects”class BandNeighborhoodAggregate(RasterOperator)The BandNeighborhoodAggregate operator.
__init__
Section titled “__init__”def __init__(source: RasterOperator, aggregate: BandNeighborhoodAggregateParams)Creates a new BandNeighborhoodAggregate operator.
BandNeighborhoodAggregateParams Objects
Section titled “BandNeighborhoodAggregateParams Objects”class BandNeighborhoodAggregateParams()Abstract base class for band neighborhood aggregate params.
from_dict
Section titled “from_dict”@classmethoddef from_dict( cls, band_neighborhood_aggregate_dict: dict[str, Any]) -> BandNeighborhoodAggregateParamsReturns a BandNeighborhoodAggregate object from a dictionary.
BandNeighborhoodAggregateFirstDerivative Objects
Section titled “BandNeighborhoodAggregateFirstDerivative Objects”@dataclassclass BandNeighborhoodAggregateFirstDerivative(BandNeighborhoodAggregateParams )The first derivative band neighborhood aggregate.
BandNeighborhoodAggregateAverage Objects
Section titled “BandNeighborhoodAggregateAverage Objects”@dataclassclass BandNeighborhoodAggregateAverage(BandNeighborhoodAggregateParams)The average band neighborhood aggregate.
Onnx Objects
Section titled “Onnx Objects”class Onnx(RasterOperator)Onnx ML operator.
__init__
Section titled “__init__”def __init__(source: RasterOperator, model: str)Creates a new Onnx operator.
PolygonRasterizationValue Objects
Section titled “PolygonRasterizationValue Objects”class PolygonRasterizationValue()The value that a polygon burns into the pixels it covers.
from_dict
Section titled “from_dict”@classmethoddef from_dict(cls, value_dict: dict[str, Any]) -> PolygonRasterizationValueReturns a value object from a dictionary.
constant
Section titled “constant”@classmethoddef constant(cls, value: float) -> PolygonRasterizationValueEach covered pixel gets the value.
@classmethoddef count(cls) -> PolygonRasterizationValueEach pixel gets the number of polygons that cover it.
attribute
Section titled “attribute”@classmethoddef attribute(cls, column: str, aggregation: PolygonRasterizationAggregation, ignore_no_data: bool = True) -> PolygonRasterizationValueEach 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.
PolygonRasterizationValueConstant Objects
Section titled “PolygonRasterizationValueConstant Objects”@dataclassclass PolygonRasterizationValueConstant(PolygonRasterizationValue)Each covered pixel gets the constant value.
PolygonRasterizationValueCount Objects
Section titled “PolygonRasterizationValueCount Objects”@dataclassclass PolygonRasterizationValueCount(PolygonRasterizationValue)Each pixel gets the number of polygons that cover it.
PolygonRasterizationValueAttribute Objects
Section titled “PolygonRasterizationValueAttribute Objects”@dataclassclass PolygonRasterizationValueAttribute(PolygonRasterizationValue)Each pixel gets the value of a numeric column, aggregated over all polygons that cover it.
PolygonRasterizationTime Objects
Section titled “PolygonRasterizationTime Objects”class PolygonRasterizationTime()How the time slices of the output raster are derived from the features.
from_dict
Section titled “from_dict”@classmethoddef from_dict(cls, time_dict: dict[str, Any]) -> PolygonRasterizationTimeReturns a time object from a dictionary.
feature_times
Section titled “feature_times”@classmethoddef feature_times(cls) -> PolygonRasterizationTimeEvery start and end time of a feature is a slice boundary.
regular
Section titled “regular”@classmethoddef regular( cls, granularity: TimeGranularity, step: int = 1, reference: datetime.datetime | np.datetime64 | None = None) -> PolygonRasterizationTimeRegular time slices of length step, aligned to reference (default: Unix epoch).
all_features
Section titled “all_features”@classmethoddef all_features(cls) -> PolygonRasterizationTimeAll features, regardless of their times, are rasterized into one time slice that is valid forever.
PolygonRasterizationTimeFeatureTimes Objects
Section titled “PolygonRasterizationTimeFeatureTimes Objects”@dataclassclass PolygonRasterizationTimeFeatureTimes(PolygonRasterizationTime)Every start and end time of a feature is a slice boundary.
PolygonRasterizationTimeRegular Objects
Section titled “PolygonRasterizationTimeRegular Objects”@dataclassclass PolygonRasterizationTimeRegular(PolygonRasterizationTime)Regular time slices that contain all features whose time intersects them.
PolygonRasterizationTimeAllFeatures Objects
Section titled “PolygonRasterizationTimeAllFeatures Objects”@dataclassclass PolygonRasterizationTimeAllFeatures(PolygonRasterizationTime)All features, regardless of their times, are rasterized into one time slice that is valid forever.
PolygonRasterization Objects
Section titled “PolygonRasterization Objects”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.
__init__
Section titled “__init__”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.