geography::STPolyFromText
static constructor STPolyFromText (called as type::STPolyFromText(...))
What changes
- Input
- WKT, WKB, GML or coordinates and SRID
- Output or change
- spatial instance
- Return type
- SQL Server return type: geography CLR return type: SqlGeography OGC type: Polygon
Syntax at a glance
STPolyFromText ( 'polygon_tagged_text' , SRID )
Work example
Use geography.STPolyFromText to construct a polygon from WKT.
Check closed rings, geography ring orientation, and SRID. Keep the geography type and SRID in the review.
Check your work The closed, non-self-intersecting polygon is valid and its geography area is measured in square metres.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT geography::STPolyFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STIsValid() AS polygon_is_valid, geography::STPolyFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STArea() AS area_m2;
Open Microsoft Learn for full syntax, permissions, and details for your version.