geofileops.clip_by_geometry#

geofileops.clip_by_geometry(input_path: str | os.PathLike[Any], output_path: str | os.PathLike[Any], clip_geometry: tuple[float, float, float, float] | str, input_layer: str | None = None, output_layer: str | None = None, columns: list[str] | None = None, explodecollections: bool = False, force: bool = False) None#

Clip all geometries in the input file by the geometry provided.

If explodecollections is False and the input and output file type is GeoPackage, the fid will be preserved. In other cases this will typically not be the case.

Parameters:
  • input_path (PathLike) – the input file

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

  • clip_geometry (Union[Tuple[float, float, float, float], str]) – the bounds or WKT geometry to clip with.

  • input_layer (str, optional) – input layer name. If None, input_path should contain only one layer. Defaults to None.

  • output_layer (str, optional) – output layer name. If None, the output_path stem is used. Defaults to None.

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

  • explodecollections (bool, optional) – True to output only simple geometries. Defaults to False.

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

See also

  • clip(): clip geometries by the features in another layer