SQL Reference
Geospatial Functions
Conversion Functions
{{ocientgeo}} conversion functions transform a specified operand to a different data type st asbinary alias of st aswkb returns the well known binary (wkb) representation of the specified geography syntax st asbinary(geo \[, xdr or ndr ] ) 136,166,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 asbinary(st point(2, 2), 'ndr'); output 010100000000000000000000400000000000000040 st asgeojson returns the geojson representation of the specified geography using the ietf standards st asgeojson( geo \[, planar conversion ] ) 178,127,350 false true left unhandled content type left unhandled content type left false unhandled content type left unhandled content type left unhandled content type left false unhandled content type left unhandled content type left unhandled content type left false unhandled content type examples this example converts a point value into a geojson representation select st asgeojson(st point(2, 2), false); output {"type" "point","coordinates" \[2,2]} this example converts an empty point value select st asgeojson(st pointfromtext('point empty'), false); output {"type" "point","coordinates" \[]} this example converts a linestring value into a geojson representation select st asgeojson(st linestring(st point(1 234, 2),st point(3 456, 5)); output {"type" "linestring","coordinates" \[\[1 234,2],\[3 456,5]]} this example again converts a linestring value select st asgeojson(st linestring(array\[st point(1 234, 2)]); output {"type" "point","coordinates" \[1 234,2]} this example converts an empty linestring value into a geojson representation select st asgeojson(st linefromtext('linestring empty'), false); output {"type" "linestring","coordinates" \[]} this example converts a polygon value into a geojson representation select st asgeojson( st polygon( array \[st point(1 234, 2),st point(3 456, 5),st point(5 678, 2),st point(1 234, 2)], array \[array\[st point(2,2 5),st point(2 1,2 6),st point(2 2,2 5),st point(2,2 5)], array \[st point(3,2 5),st point(3 1,2 6),st point(3 2,2 5),st point(3,2 5)]]), false); output {"type" "polygon","coordinates" \[\[\[1 234,2],\[3 456,5],\[5 678,2],\[1 234,2]],\[\[2,2 5],\[2 1,2 6],\[2 2,2 5],\[2,2 5]],\[\[3,2 5],\[3 1,2 6],\[3 2,2 5],\[3,2 5]]]} this example again converts a polygon value select st asgeojson( st polygon( array \[st point(1 234, 2),st point(3 456, 5),st point(5 678, 2),st point(1 234, 2)], array \[array\[st point(2,2 5),st point(2 1,2 6),st point(2 2,2 5),st point(3,2 5)], array \[st point(3,2 5),st point(3 2,2 5),st point(3,2 5)]]), false); output {"type" "polygon","coordinates" \[\[\[1 234,2],\[3 456,5],\[5 678,2],\[1 234,2]]]} this example converts a two point polygon , which results in a linestring type in the geojson representation select st asgeojson( st polygon( st linestring(st point(1 234, 2), st point(3 456, 5))), false); output {"type" "linestring","coordinates" \[\[1 234,2],\[3 456,5]]} this example converts a single point polygon , which results in a point type in the geojson representation select st asgeojson(st polygon(st point(1 234, 2)), false); output {"type" "point","coordinates" \[1 234,2]} this example converts an empty polygon value into a geojson representation select st asgeojson(st polygonfromtext('polygon empty'), false); output {"type" "polygon","coordinates" \[]} st aslatlontext returns a string that represents geographic coordinates of a specified point in the specified format st aslatlontext(point, \[ output format ] ) 166,128,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 aslatlontext(st point(10 2342342, 2 32498), 'd d degrees mm mm minutes c'); output '2 0 degrees 19 50 minutes s 10 0 degrees 14 05 minutes e' st astext alias of st aswkt and st ewkt returns the well known text (wkt) representation of the specified geography if you use st asewkt , the database prepends the resultant string with srid=4326; st astext(geo) 109,187,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 astext(st polygon(st linestring('linestring(1 2, 1 3, 1 3, 1 2)'))); output polygon((1 2, 1 3, 1 3, 1 2)) st asewkt for usage, see conversion functions /#stastext st aswkt alias of conversion functions /#stastext st aswkb alias of conversion functions /#stasbinary st geohash returns a string that represents the geohash of the input point this function also accepts an optional second argument to specify the length of the geohash result if you specify any argument as null, then the function returns null st geohash(point \[, precision ] ) 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 left unhandled content type left unhandled content type left unhandled content type example select st geohash(st point( 126, 48)); output c0w3hc0w3hf1s70w3hf1s70w3 related links data types docid\ ogtviwl gtbgv0chhrh 3 attribute functions docid\ b7ofhdvlpchajicwqdpfb