pyinterp.geometry.cartesian.algorithms.is_valid

Contents

pyinterp.geometry.cartesian.algorithms.is_valid#

pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.Point, return_reason: bool = False) object#
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.Segment, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.Box, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.LineString, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.Ring, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.Polygon, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.MultiPoint, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.MultiLineString, return_reason: bool = False) object
pyinterp.geometry.cartesian.algorithms.is_valid(geometry: pyinterp.core.geometry.cartesian.MultiPolygon, return_reason: bool = False) object

Check if a geometry is valid according to OGC standards.

Validity rules (OGC Simple Features specification):

  • Points: Always valid (unless coordinates are NaN/Inf)

  • LineStrings: Must have at least 2 points

  • Rings: Must be closed and have at least 4 points

  • Polygons: Outer ring must be counter-clockwise, inner rings clockwise, rings must not cross each other or touch except at single points

  • MultiPolygons: All constituent polygons must be valid

Parameters:

geometry – Geometric object to check.

Returns:

bool

If called without return_reason (True if the geometry is valid, false otherwise.).

tuple[bool, str]

If called with return_reason=True, returns a tuple where the first element is a boolean indicating validity, and the second element is a string describing the reason for invalidity (empty string if valid).