Geometry Validation

geometry validations


source

ValidationError


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

Common base class for all non-exit exceptions.


source

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


source

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


source

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


source

OrientationValidator.check


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

Checks if orientation is counter clockwise


source

OrientationValidator.fix


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

Fixes orientation if orientation is clockwise


source

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


source

CrsBoundsValidator.get_check_arguments


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

Return check arguments


source

CrsBoundsValidator.check


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

Checks if polygon is within bounds of crs.


source

CrsBoundsValidator.fix


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

No fix available


source

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


source

SelfIntersectingValidator.check


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

source

SelfIntersectingValidator.fix


def fix(
    geometry:BaseGeometry
)->BaseGeometry:

Fix intersection geometry by applying shapely.validation.make_valid


source

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


source

NullValidator.check


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

Checks if polygon is null


source

NullValidator.fix


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

No fix available


source

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


source

AreaValidator.check


def check(
    geometry:BaseGeometry
)->bool:

Checks if area is greater than 0


source

AreaValidator.fix


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

No fix available


source

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


source

GeometryValidation.validate_all


def validate_all(
    
)->GeoDataFrame:

Sequentially run validators