geofileops.isvalid#

geofileops.isvalid(input_path: str | os.PathLike[Any], output_path: str | os.PathLike[Any] | None = None, only_invalid: bool = True, input_layer: str | None = None, output_layer: str | None = None, columns: list[str] | None = None, explodecollections: bool = False, validate_attribute_data: bool = False, nb_parallel: int | None = None, batchsize: int = -1, force: bool = False) bool#

Checks for all geometries in the geofile if they are valid.

If there are no invalid geometries, no output file will be created and isvalid will return True. If there are invalid geometries isvalid returns False and the output file contains a row for each invalid geometry. Each row will contain the following information:

  • geometry column: contains a point where the invalidity occurs. For example, for a self-intersecting polygon, this will be the point where the self-intersection occurs. If the geometry is valid, this will be null.

  • isvalid: a boolean column indicating if the geometry is valid or not.

  • reason: if the geometry is invalid, this column contains a text with the reason why the geometry is invalid. If the geometry is valid, this will be null.

  • The other columns from the input file, depending on the columns parameter.

Parameters:
  • input_path (PathLike) – The input file.

  • output_path (PathLike, optional) – The output file path. If not specified the result will be written in a new file alongside the input file. Defaults to None.

  • only_invalid (bool, optional) – is deprecated and will be removed in a future version. The output will always contain only invalid geometries.

  • 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) – is deprecated and will be removed in a future version.

  • validate_attribute_data (bool, optional) – True to validate if all attribute data can be read. Defaults to False.

  • nb_parallel (int | None, optional) – the number of parallel workers to use. If None, the preference set in the nb_parallel configuration option is used, which defaults to the number of CPU cores available. For more information, see options.set_nb_parallel(). Defaults to None.

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

Returns:

True if all geometries were valid.

Return type:

bool

See also

  • make_valid(): make the geometries in the input layer valid