geography.MakeValid
spatial method MakeValid (instance.MakeValid(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- geography
- Return type
- SQL Server return type: geography CLR return type: SqlGeography
Syntax at a glance
.MakeValid ()
Work example
Use geography.MakeValid to repair an invalid spatial value before a topology operation.
Compare the repaired output with the source because repair can split or change its type. Keep the geography type and SRID in the review.
Check your work MakeValid returns a valid instance and may change the original shape's type.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT p.shape.MakeValid().STIsValid() AS repaired_is_valid, p.shape.MakeValid().STGeometryType() AS repaired_type FROM (VALUES (CAST('POLYGON((2 2, 4 4, 4 2, 2 4, 2 2))' AS geography))) AS p(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.