AlignerResult

aligner.AlignerResult(process_results)

Stores and processes the results from the alignment operation.

This class manages the lifecycle of alignment results, including enrichment with geometric metrics (like area or length change), filtering by result type, and exporting to GeoJSON format.

Attributes

Name Type Description
results Dict[InputId, Dict[float, Optional[ProcessResult]]] A nested dictionary where the outer key is the theme ID and the inner key is the relevant distance used during processing.
metadata Optional[Any] Optional metadata about the overall alignment operation.

Notes

The class acts as a post-processor. It takes the raw output from the geometric engines and calculates semantic differences before exporting.

graph TD
    Raw[Raw Process Results] --> AR[AlignerResult]
    AR --> |get_results| Enriched[Enriched with Area/Length Metrics]
    Enriched --> |get_results_as_geojson| GeoJSON[GeoJSON FeatureCollection]
    GeoJSON --> |save_results| Disk[Local .geojson files]

Examples

>>> # Initializing and saving results
>>> result_obj = AlignerResult(raw_results)
>>> result_obj.save_results(aligner, path="./output_folder")

Methods

Name Description
export Unified export entry point for processed alignment results.
get_results Retrieves results enriched with geometric metrics and filtered by type.
get_results_as_geodataframe Converts the results into a flat GeoDataFrame.
get_results_as_geojson Converts the results into a GeoJSON FeatureCollection format.
save_results Exports the results as multiple GeoJSON files to a directory.
to_gdf Export processed results as a GeoDataFrame.
to_geojson Export processed results as GeoJSON (dictionary payload).
to_geojson_file Write processed results to a GeoJSON file.
to_gpkg Write processed results to a GeoPackage file.
to_parquet Write processed results to a Parquet file.

export

aligner.AlignerResult.export(
    aligner,
    format,
    path=None,
    *,
    layer=None,
    result_type=AlignerResultType.PROCESSRESULTS,
    profile='full',
    crs=None,
    fields=None,
    include_geometry=True,
    include_metadata=True,
    add_original_attributes=False,
)

Unified export entry point for processed alignment results.

Supported formats: gdf, geojson, json, parquet, gpkg.

get_results

aligner.AlignerResult.get_results(
    aligner,
    result_type=AlignerResultType.PROCESSRESULTS,
)

Retrieves results enriched with geometric metrics and filtered by type.

This method mutates the stored ProcessResult objects by adding calculated difference metrics (e.g., symmetrical area change) to their properties.

Parameters

Name Type Description Default
aligner Aligner The ‘Aligner’ object used to access thematic data and comparison logic. required
result_type AlignerResultType Filters the results based on status. Defaults to PROCESSRESULTS. AlignerResultType.PROCESSRESULTS

Returns

Name Type Description
Dict[InputId, Dict[float, Optional[ProcessResult]]] A dictionary of filtered and enriched results.

Raises

Name Type Description
ValueError If an unsupported result_type is provided.

get_results_as_geodataframe

aligner.AlignerResult.get_results_as_geodataframe(
    aligner,
    result_type=AlignerResultType.PROCESSRESULTS,
    add_metadata=False,
    add_original_attributes=False,
)

Converts the results into a flat GeoDataFrame.

The resulting GeoDataFrame contains one row per (theme_id, relevant_distance), geometry columns (result, result_diff, …), and flattened dictionary columns (e.g. properties__*).

get_results_as_geojson

aligner.AlignerResult.get_results_as_geojson(
    aligner,
    result_type=AlignerResultType.PROCESSRESULTS,
    add_metadata=False,
    add_original_attributes=False,
)

Converts the results into a GeoJSON FeatureCollection format.

Parameters

Name Type Description Default
aligner Aligner The ‘Aligner’ object providing CRS and thematic metadata. required
result_type AlignerResultType The type of results to export. Defaults to PROCESSRESULTS. AlignerResultType.PROCESSRESULTS
add_metadata bool If True, includes the descriptive comparison observation in properties. False
add_original_attributes bool If True, includes original thematic attributes in the output. False

Returns

Name Type Description
Dict[str, Any] A dictionary representing a GeoJSON FeatureCollection.

Raises

Name Type Description
ValueError If self.results is empty or None.

save_results

aligner.AlignerResult.save_results(
    aligner,
    path,
    result_type=AlignerResultType.PROCESSRESULTS,
    add_metadata=False,
    add_original_attributes=False,
)

Exports the results as multiple GeoJSON files to a directory.

Creates separate files for original results, differences, and specific area changes (added/removed).

Parameters

Name Type Description Default
aligner Aligner The ‘Aligner’ object for spatial context. required
path str Target directory path where files will be created. required
result_type AlignerResultType Type of results to export. Defaults to PROCESSRESULTS. AlignerResultType.PROCESSRESULTS
add_metadata bool Whether to include alignment observations in the output. False
add_original_attributes bool Whether to include original feature attributes. False

Notes

The output files follow the naming convention: {result_type}_{name}.geojson.

to_gdf

aligner.AlignerResult.to_gdf(
    aligner,
    *,
    result_type=AlignerResultType.PROCESSRESULTS,
    profile='full',
    fields=None,
    include_geometry=True,
    add_metadata=False,
    add_original_attributes=False,
)

Export processed results as a GeoDataFrame.

Parameters

Name Type Description Default
aligner Aligner Aligner instance used to resolve thematic id field and CRS. required
result_type AlignerResultType Result subset to export. AlignerResultType.PROCESSRESULTS
profile str Output profile: minimal, full or analysis. 'full'
fields list[str] Optional whitelist of columns to keep. None
include_geometry bool Whether to keep the active geometry column. True
add_metadata bool Include BRDR metadata columns when available. False
add_original_attributes bool Include original thematic properties. False

to_geojson

aligner.AlignerResult.to_geojson(
    aligner,
    *,
    result_type=AlignerResultType.PROCESSRESULTS,
    profile='full',
    fields=None,
    include_geometry=True,
    include_metadata=True,
    add_original_attributes=False,
)

Export processed results as GeoJSON (dictionary payload).

to_geojson_file

aligner.AlignerResult.to_geojson_file(
    aligner,
    path,
    *,
    result_type=AlignerResultType.PROCESSRESULTS,
    profile='full',
    fields=None,
    include_geometry=True,
    include_metadata=True,
    add_original_attributes=False,
)

Write processed results to a GeoJSON file.

to_gpkg

aligner.AlignerResult.to_gpkg(
    aligner,
    path,
    *,
    layer='results',
    result_type=AlignerResultType.PROCESSRESULTS,
    profile='full',
    fields=None,
    include_geometry=True,
    include_metadata=True,
    add_original_attributes=False,
)

Write processed results to a GeoPackage file.

to_parquet

aligner.AlignerResult.to_parquet(
    aligner,
    path,
    *,
    result_type=AlignerResultType.PROCESSRESULTS,
    profile='full',
    fields=None,
    include_geometry=True,
    include_metadata=True,
    add_original_attributes=False,
)

Write processed results to a Parquet file.