SQL Reference
Geospatial Functions
Polygon Constructors
{{ocientgeo}} polygon constructors use geospatial data to create a polygon object st forceccw creates a standardized polygon from an existing one {{ocient}} defines standardized as the exterior being counterclockwise (ccw) and all holes being clockwise (cw) oriented syntax st forceccw(polygon) 136,157,350 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example select st forceccw(st polygon('polygon((0 0,0 1,1 1,1 0,0 0))')); output polygon((0 0,1 0,1 1,0 1,0 0)) st makepolygon alias for polygon constructors /#stpolygon st polygon creates a polygon st polygon(geo) creates a polygon from the specified point , point array, linestring , or polygon geography syntax st polygon(geo) 136,147,350 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example select st polygon( st linestring( st point \[]\( st point(1, 2), st point(1, 3), st point(1, 4), st point(1, 2)))); output polygon((1 2,1 3,1 4,1 2)) st polygon(char) alias for st makepolygon(char) creates a polygon from the specified char representing a polygon in wkt format syntax st polygon(char) 136,176,350 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example select st polygon('polygon((1 2,1 3,1 4,1 2))'); output polygon((1 2,1 3,1 4,1 2)) st polygon(binary) alias for st polygonfromwkb(binary) creates a polygon from the specified binary the binary value must represent a polygon in wkb format syntax st polygon(binary) 136,153,350 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example select st polygon(binary('0x01030000000100000005000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f000000000000f03f000000000000000000000000000000000000000000000000')); output polygon((0 0,0 1,1 1,1 0,0 0)) st polygon(outer ring, inner rings) alias for st makepolygon(outerring, innerrings) creates a polygon from the specified outer ring (that must be either a point , point array, or linestring ) and the array of interior rings (closed lines) the interior of the polygon is on the left when traveling around the exterior ring the interior of a hole is on the right when traveling around a hole syntax st polygon(outer ring, inner rings) 136,170,350 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example select st polygon( st linestring(st point \[]\(st point(1, 2))), st linestring \[]\(st linestring(st point \[]\(st point(1, 2))))); output polygon((1 000000 2 000000), (1 000000 2 000000)) st polygonfromwkb alias for polygon constructors /#stpolygonbinary st polygonfromewkt alias for the polygon constructors /#stpolygon constructor creates a polygon using an ewkt formatted char as an input argument syntax st polygonfromewkt(char) 135,173,351 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example select st polygonfromewkt('srid=4326;polygon((1 2,1 3,1 4,1 2))'); output polygon((1 2,1 3,1 4,1 2)) st polygonfromgeojson creates a polygon represented by the specified geojson value as an input argument syntax st polygonfromgeojson(geojson \[, geodesic ] ) 135,140,352 false true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type examples in this example, the function produces an empty polygon value from the geojson representation select st polygonfromgeojson('{"type" "polygon","coordinates" \[]}',false); output polygon empty in this example, the function produces a polygon value from the geojson representation select st polygonfromgeojson( '{"type" "polygon","coordinates" \[\[\[1,1],\[1,5],\[5,5],\[5,1]]]}', false); output polygon((1 1, 1 5, 5 5, 5 1)) st polygonfromtext alias for polygon constructors /#stpolygonchar st wholeearth returns the database internal representation of the whole earth polygon the spatial operators docid\ aawcrtqvk1nkc0hcgthci function returns this polygon value, with the envelope set as the entire earth gis specifications do not describe a canonical polygon for the whole earth, but this value serves as the ocient canonical polygon the whole earth polygon is also equivalent to st polygon('polygon((0 0,0 0,0 0,0 0'))) , which can have a separate meaning in other gis implementations syntax st wholeearth() example select st wholeearth(); output polygon((0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0)) related links data types docid\ ogtviwl gtbgv0chhrh 3 conversion functions docid\ uq rlzenk gtplkr2hyb5