Geometry Validation

geometry validations


ValidationError


def ValidationError(
    args:VAR_POSITIONAL, kwargs:VAR_KEYWORD
):

Common base class for all non-exit exceptions.


BaseValidator


def BaseValidator(
    add_new_column:bool=True, # Add new column to show errors
    apply_fix:bool=True, # Update geometry
):

Abstract Base Class for single validator


BaseValidator.validate


def validate(
    gdf:GeoDataFrame, # GeoDataFrame to validate
    clone:bool=True, # Apply validation to copy
)->GeoDataFrame:

Method that checks the validity of a each geometry and applies a fix to these geometries or raise a warning


OrientationValidator


def OrientationValidator(
    add_new_column:bool=True, # Add new column to show errors
    apply_fix:bool=True, # Update geometry
):

Checks and fixes Orientation of the geometry to ensure it follows a counter-clockwise orientation


OrientationValidator.check


def check(
    geometry:BaseGeometry, # Geometry to validate
)->bool:

Checks if orientation is counter clockwise


OrientationValidator.fix


def fix(
    geometry:BaseGeometry, # Geometry to fix
)->BaseGeometry:

Fixes orientation if orientation is clockwise


CrsBoundsValidator


def CrsBoundsValidator(
    add_new_column:bool=True, # Add new column to show errors
    apply_fix:bool=True, # Update geometry
):

Checks bounds of the geometry to ensure it is within bounds of the crs


CrsBoundsValidator.get_check_arguments


def get_check_arguments(
    gdf:GeoDataFrame, # GeoDataFrame to check
)->dict:

Return check arguments


CrsBoundsValidator.check


def check(
    geometry:BaseGeometry, # Geometry to validate
    gdf:GeoDataFrame, # GeoDataframe to check
)->bool:

Checks if polygon is within bounds of crs.


CrsBoundsValidator.fix


def fix(
    geometry:BaseGeometry, # Geometry to fix
)->BaseGeometry: # pragma: no cover

No fix available


SelfIntersectingValidator


def SelfIntersectingValidator(
    add_new_column:bool=True, # Add new column to show errors
    apply_fix:bool=True, # Update geometry
):

Checks bounds of the geometry to ensure it is within bounds or crs


SelfIntersectingValidator.check


def check(
    geometry:BaseGeometry, # Geometry to check
)->bool:

SelfIntersectingValidator.fix


def fix(
    geometry:BaseGeometry
)->BaseGeometry:

Fix intersection geometry by applying shapely.validation.make_valid


NullValidator


def NullValidator(
    add_new_column:bool=True, # Add new column to show errors
    apply_fix:bool=True, # Update geometry
):

Checks bounds of the geometry to ensure it is within bounds or crs


NullValidator.check


def check(
    geometry:BaseGeometry
)->bool: # Geometry to check

Checks if polygon is null


NullValidator.fix


def fix(
    geometry:BaseGeometry, # Geometry to fix
)->BaseGeometry: # pragma: no cover

No fix available


AreaValidator


def AreaValidator(
    add_new_column:bool=True, # Add new column to show errors
    apply_fix:bool=True, # Update geometry
):

Checks area of the geometry to ensure it greater than 0


AreaValidator.check


def check(
    geometry:BaseGeometry
)->bool:

Checks if area is greater than 0


AreaValidator.fix


def fix(
    geometry:BaseGeometry, # Geometry to fix
)->BaseGeometry: # pragma: no cover

No fix available


GeometryValidation


def GeometryValidation(
    gdf:GeoDataFrame, # GeoDataFrame to validate
    validators:Sequence=('null', 'self_intersecting', 'orientation', 'crs_bounds', 'area'), # Validators to apply
    add_validation_columns:bool=True, # Add column to show errors
    apply_fixes:bool=True, # Update geometry
)->GeoDataFrame:

Applies a list of validation checks and tries to fix them


GeometryValidation.validate_all


def validate_all(
    
)->GeoDataFrame:

Sequentially run validators