Skip to content

GeodataPostprocessor

Bases: ABC, FromConfigMixin

Abstract class for geodata postprocessors

Geodata postprocessors are callables that postprocess geodata. The geodata postprocessor is used by the pipeline to postprocess the resulting geodata, which is the vectorized output of the model's inference.

Currently implemented geodata postprocessors
  • ClipPostprocessor: Clips the polygons based on the mask extent
  • CompositePostprocessor: Composes multiple geodata postprocessors
  • FieldNamePostprocessor: Renames the fields
  • FillPostprocessor: Fills holes in the polygons
  • SievePostprocessor: Sieves the polygons
  • SimplifyPostprocessor: Simplifies the polygons by applying the Douglas-Peucker algorithm
  • ValuePostprocessor: Maps the values of a field

__call__ abstractmethod

Postprocesses the geodata.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


ClipPostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that clips the polygons based on the mask extent

PARAMETER DESCRIPTION
mask

geodataframe of the mask (may contain multiple polygons)

TYPE: gpd.GeoDataFrame

from_config classmethod

Creates a clip postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: ClipPostprocessorConfig

RETURNS DESCRIPTION
ClipPostprocessor

clip postprocessor

__call__

Postprocesses the geodata by clipping the polygons based on the mask extent.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


ClipPostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of ClipPostprocessor

ATTRIBUTE DESCRIPTION
mask

path to the geodataframe of the mask (may contain multiple polygons)

TYPE: Path


CompositePostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that composes multiple geodata postprocessors

PARAMETER DESCRIPTION
geodata_postprocessors

geodata postprocessors

TYPE: list[GeodataPostprocessor]

from_config classmethod

Creates a composite postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: CompositePostprocessorConfig

RETURNS DESCRIPTION
CompositePostprocessor

composite postprocessor

__call__

Postprocesses the geodata with each geodata postprocessor.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


CompositePostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of CompositePostprocessor

ATTRIBUTE DESCRIPTION
geodata_postprocessors_configs

configurations of the geodata postprocessors

TYPE: list[GeodataPostprocessorConfig]


GeodataPostprocessorConfig

Bases: pydantic.BaseModel

Configuration for geodata postprocessors

ATTRIBUTE DESCRIPTION
name

name of the geodata postprocessor

TYPE: str

config

configuration of the geodata postprocessor

TYPE: ClipPostprocessorConfig | FieldNamePostprocessorConfig | FillPostprocessorConfig | SievePostprocessorConfig | SimplifyPostprocessorConfig | ValuePostprocessorConfig


FieldNamePostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that renames the fields

Examples:

Assume the geodataframe has the field 'class'.

You can rename the field 'class' to 'type'.

>>> field_name_postprocessor = FieldNamePostprocessor(
...     mapping={
...         'class': 'type',
...     },
... )
...
>>> gdf = field_name_postprocessor(gdf)
PARAMETER DESCRIPTION
mapping

mapping of the field names (old field name: new field name)

TYPE: dict

from_config classmethod

Creates a field name postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: FieldNamePostprocessorConfig

RETURNS DESCRIPTION
FieldNamePostprocessor

field name postprocessor

__call__

Postprocesses the geodata by renaming the fields.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


FieldNamePostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of FieldNamePostprocessor

ATTRIBUTE DESCRIPTION
mapping

mapping of the field names (old field name: new field name)

TYPE: dict


FillPostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that fills holes in the polygons

PARAMETER DESCRIPTION
max_area

maximum area of the holes to retain in square meters

TYPE: float

from_config classmethod

Creates a fill postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: FillPostprocessorConfig

RETURNS DESCRIPTION
FillPostprocessor

fill postprocessor

__call__

Postprocesses the geodata by filling holes in the polygons.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


FillPostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of FillPostprocessor

ATTRIBUTE DESCRIPTION
max_area

maximum area of the holes to retain in square meters

TYPE: float


SievePostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that sieves the polygons

PARAMETER DESCRIPTION
min_area

minimum area of the polygons to retain in square meters

TYPE: float

from_config classmethod

Creates a sieve postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: SievePostprocessorConfig

RETURNS DESCRIPTION
SievePostprocessor

sieve postprocessor

__call__

Postprocesses the geodata by sieving the polygons.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


SievePostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of SievePostprocessor

ATTRIBUTE DESCRIPTION
min_area

minimum area of the polygons to retain in square meters

TYPE: float


SimplifyPostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that simplifies the polygons by applying the Douglas-Peucker algorithm

PARAMETER DESCRIPTION
tolerance

tolerance of the Douglas-Peucker algorithm in meters (a lower value will result in less simplification, a higher value will result in more simplification, a value equal to the ground sampling distance is recommended)

TYPE: float

from_config classmethod

Creates a simplify postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: SimplifyPostprocessorConfig

RETURNS DESCRIPTION
SimplifyPostprocessor

simplify postprocessor

__call__

Postprocesses the geodata by simplifying the polygons.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


SimplifyPostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of SimplifyPostprocessor

ATTRIBUTE DESCRIPTION
tolerance

tolerance of the Douglas-Peucker algorithm in meters (a lower value will result in less simplification, a higher value will result in more simplification, a value equal to the ground sampling distance is recommended)

TYPE: float


ValuePostprocessor

Bases: GeodataPostprocessor

Geodata postprocessor that maps the values of a field

Examples:

Assume the geodataframe has the values 0, 1 and 2 in the field 'class'.

You can map the values 0, 1 and 2 to 'class_1', 'class_2' and 'class_3'.

>>> value_postprocessor = ValuePostprocessor(
...     mapping={
...         0: 'class_1',
...         1: 'class_2',
...         2: 'class_3',
...     },
...     field_name='class',
... )
...
>>> gdf = value_postprocessor(gdf)
PARAMETER DESCRIPTION
mapping

mapping of the values (old value: new value)

TYPE: dict

field_name

name of the field

TYPE: str DEFAULT: 'class'

from_config classmethod

Creates a value postprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: ValuePostprocessorConfig

RETURNS DESCRIPTION
ValuePostprocessor

value postprocessor

__call__

Postprocesses the geodata by mapping the values of a field.

PARAMETER DESCRIPTION
gdf

geodataframe

TYPE: gpd.GeoDataFrame

RETURNS DESCRIPTION
gpd.GeoDataFrame

postprocessed geodataframe


ValuePostprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of ValuePostprocessor

ATTRIBUTE DESCRIPTION
mapping

mapping of the values (old value: new value)

TYPE: dict

field_name

name of the field

TYPE: str