geofileops.dissolve_within_distance#
- geofileops.dissolve_within_distance(input_path: Path, output_path: Path, distance: float, gridsize: float, close_internal_gaps: bool = False, input_layer: Optional[str] = None, output_layer: Optional[str] = None, nb_parallel: int = -1, batchsize: int = -1, force: bool = False)#
Dissolve geometries that are within the distance specified.
The output layer will contain the dissolved geometries where all gaps between the input geometries up to
distance
are closed.Notes
Only tested on polygon input.
Gaps between the individual polygons of multipolygon input features will also be closed.
The polygons in the output file are exploded to simple geometries.
No attributes from the input layer are retained.
If
close_internal_gaps
is False, the default, agridsize
> 0 (E.g. 0.000001) should be specified, otherwise some input boundary gaps could still be closed due to rounding side effects.
- Alternative names:
ArcMap: aggregate_polygons (similar functionality)
Keywords: merge, dissolve, aggregate, snap, close gaps, union
- Parameters:
input_path (PathLike) – the input file.
output_path (PathLike) – the file to write the result to.
distance (float) – the maximum distance between geometries to be dissolved.
gridsize (float, optional) – the size of the grid the coordinates of the ouput will be rounded to. Eg. 0.001 to keep 3 decimals. Value 0.0 doesn’t change the precision. If
close_boundary_gaps
is False, the default, agridsize
> 0 (E.g. 0.000001) should be specified, otherwise some boundary gaps in the input geometries could still be closed due to rounding side effects.close_internal_gaps (bool, optional) – also close gaps, strips or holes in the input geometries that are narrower than the
distance
specified. E.g. small holes, narrow strips starting at the boundary,… Defaults to False.input_layer (str, optional) – input layer name. Optional if the input file only contains one layer.
output_layer (str, optional) – input layer name. Optional if the input file only contains one layer.
nb_parallel (int, optional) – the number of parallel processes to use. Defaults to -1: use all available CPUs.
batchsize (int, optional) – indicative number of rows to process per batch. A smaller batch size, possibly in combination with a smaller
nb_parallel
, will reduce the memory usage. Defaults to -1: (try to) determine optimal size automatically.force (bool, optional) – overwrite existing output file(s). Defaults to False.