maup.repair module
- maup.repair.autorepair(geometries, relative_threshold=0.1, force_polygons=False)[source]
Uses simplistic algorithms to repair most gaps and overlaps. Additional optional argument provided that can drop any fragmented line segments that may occur while using shapely’s make valid function. Should work by default.
The default relative_threshold is 0.1. This default is chosen to include tiny overlaps that can be safely auto-fixed while preserving major overlaps that might indicate deeper issues and should be handled on a case-by-case basis. Set relative_threshold=None to attempt to resolve all overlaps. See resolve_overlaps() and close_gaps() for more.
For a more careful repair that takes adjacencies and higher-order overlaps between geometries into account, consider using smart_repair instead.
- maup.repair.close_gaps(geometries, relative_threshold=0.1, force_polygons=False)[source]
Closes gaps between geometries by assigning the hole to the polygon that shares the greatest perimeter with the hole.
If the area of the gap is greater than relative_threshold times the area of the polygon, then the gap is left alone. The default value of relative_threshold is 0.1. This is intended to preserve intentional gaps while closing the tiny gaps that can occur as artifacts of geospatial operations. Set relative_threshold=None to attempt close all gaps. Due to floating point precision issues, all gaps may not be closed.
Optional “force_polygons” argument included to apply an automatic filter non-polygonal fragments during operation.
- maup.repair.count_overlaps(shp)[source]
Counts overlaps between geometries. Code is taken directly from the resolve_overlaps function in maup.
- maup.repair.doctor(source, target=None, silent=False, accept_holes=False)[source]
Detects quality issues in a given set of source and target geometries. Quality issues include overlaps, gaps, invalid geometries, non-perfect tiling, and not entirely overlapping source and targets. If maup.doctor() returns True, votes should not be lost when prorating or assigning (beyond a few due to rounding, etc.). Passing a target to doctor is optional.
If silent is True, then print outputs are suppressed. (Default is silent = False.)
If accept_holes is True, then holes alone do not cause doctor to return a value of False. (Default is accept_holes = False.)
- maup.repair.expand_to(source, target, force_polygons=False)[source]
Expands the source geometries to the target geometries.
- maup.repair.holes_of_union(geometries)[source]
Returns any holes in the union of the given geometries.
- maup.repair.make_valid_polygons(geometries, force_polygons=True)[source]
Extended make valid function with optional filter for non polygonal data from the output.
- maup.repair.quick_repair(geometries, relative_threshold=0.1, force_polygons=False)[source]
New name for autorepair function from Maup 1.x. Uses simplistic algorithms to repair most gaps and overlaps.
The default relative_threshold is 0.1. This default is chosen to include tiny overlaps that can be safely auto-fixed while preserving major overlaps that might indicate deeper issues and should be handled on a case-by-case basis. Set relative_threshold=None to attempt to resolve all overlaps. See resolve_overlaps() and close_gaps() for more.
For a more careful repair that takes adjacencies and higher-order overlaps between geometries into account, consider using smart_repair instead.
- maup.repair.remove_repeated_vertices(geometries)[source]
Removes repeated vertices. Vertices are considered to be repeated if they appear consecutively, excluding the start and end points.
- maup.repair.resolve_overlaps(geometries, relative_threshold=0.1, force_polygons=False)[source]
For any pair of overlapping geometries, assigns the overlapping area to the geometry that shares the greatest perimeter with the overlap. Returns the GeoSeries of geometries, which will have no overlaps.
If the ratio of the overlap’s area to either of the overlapping geometries’ areas is greater than relative_threshold, then the overlap is ignored. The default relative_threshold is 0.1. This default is chosen to include tiny overlaps that can be safely auto-fixed while preserving major overlaps that might indicate deeper issues and should be handled on a case-by-case basis. Set relative_threshold=None to attempt to resolve all overlaps. Due to floating point precision issues, all overlaps may not be resolved.
Optional “force_polygons” argument included to apply an automatic filter non-polygonal fragments during operation.