is_valid
Validate geometry data for GIS operations by checking if it meets geospatial standards and can be used in spatial analysis.
Instructions
Check if a geometry is valid.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:437-450 (handler)The handler function for the 'is_valid' MCP tool. It parses WKT geometry using Shapely, checks if it is valid with geom.is_valid, and returns a dictionary containing the validation status.@gis_mcp.tool() def is_valid(geometry: str) -> Dict[str, Any]: """Check if a geometry is valid.""" try: from shapely import wkt geom = wkt.loads(geometry) return { "status": "success", "is_valid": bool(geom.is_valid), "message": "Geometry validation completed successfully" } except Exception as e: logger.error(f"Error validating geometry: {str(e)}") raise ValueError(f"Failed to validate geometry: {str(e)}")
- src/gis_mcp/shapely_functions.py:437-437 (registration)The @gis_mcp.tool() decorator registers the is_valid function as an MCP tool.@gis_mcp.tool()
- Resource listing that includes 'is_valid' among available validation operations.@gis_mcp.resource("gis://operations/validation") def get_validation_operations() -> Dict[str, List[str]]: """List available validation operations.""" return { "operations": [ "is_valid", "make_valid", "simplify" ] }