geofileops.erase#

geofileops.erase(input_path: Union[str, os.PathLike[Any]], erase_path: Union[str, os.PathLike[Any]], output_path: Union[str, os.PathLike[Any]], input_layer: Optional[str] = None, input_columns: Optional[List[str]] = None, erase_layer: Optional[str] = None, output_layer: Optional[str] = None, explodecollections: bool = False, gridsize: float = 0.0, where_post: Optional[str] = None, nb_parallel: int = -1, batchsize: int = -1, subdivide_coords: int = 2000, force: bool = False)#

Erase all geometries in the erase layer from the input layer.

Clarifications:
  • every row in the input layer will result in maximum one row in the output layer.

  • columns from the erase layer cannot be retained.

Alternative names:
  • QGIS: difference

Parameters:
  • input_path (PathLike) – The file to erase from.

  • erase_path (PathLike) – The file with the geometries to erase with.

  • output_path (PathLike) – the file to write the result to

  • input_layer (str, optional) – input layer name. Optional if the file only contains one layer.

  • input_columns (List[str], optional) – list of columns to retain. If None, all standard columns are retained. In addition to standard columns, it is also possible to specify “fid”, a unique index available in all input files. Note that the “fid” will be aliased eg. to “fid_1”. Defaults to None.

  • erase_layer (str, optional) – erase layer name. Optional if the file only contains one layer.

  • output_layer (str, optional) – output layer name. Optional if the file only contains one layer.

  • explodecollections (bool, optional) – True to convert all multi-geometries to singular ones after the dissolve. Defaults to False.

  • 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. Defaults to 0.0.

  • where_post (str, optional) – SQL filter to apply after all other processing, including e.g. explodecollections. It should be in sqlite syntax and spatialite reference functions can be used. Defaults to None.

  • 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.

  • subdivide_coords (int, optional) – the input geometries will be subdivided to parts with about subdivide_coords coordinates during processing which can offer a large speed up for complex geometries. Subdividing can result in extra collinear points being added to the boundaries of the output. If < 0, no subdividing is applied. Defaults to 2000.

  • force (bool, optional) – overwrite existing output file(s). Defaults to False.