Geometry Outputs

st_asBinary

Array[Byte] st_asBinary(Geometry geom)

This function returns Geometry geom in WKB representation.

Example:

  • Query command:

    select st_asBinary(st_geomFromWKT(location)) from geotbl where id='1'

  • The query result is as follows:
    AAAAAAMAAAABAAAABUA+AAAAAAAAQCQAAAAAAABARAAAAAAAAEBEAAAAAAAAQDQAAAAAAABARAAAAAAAAEAkAAAAAAAAQDQAAAAAAABAPgAAAAAAAEAkAAAAAAAA

st_asGeoJSON

String st_asGeoJSON(Geometry geom)

This function returns Geometry geom in GeoJSON representation.

Example:

  • Query command:

    select st_asGeoJSON(st_geomFromWKT(location)) from geotbl where id='3'

  • The query result is as follows:
    {"type":"MultiPolygon","coordinates":[[[[30,20],[45,40],[10,40],[30,20]]],[[[15,5],[40,10],[10,20],[5,10],[15,5]]]]}

st_asLatLonText

String st_asLatLonText(Point p)

This function returns a String describing the latitude and longitude of Point p in degrees, minutes, and seconds. (This presumes that the units of the coordinates of p are latitude and longitude.)

Example:

  • Query command:

    select st_asLatLonText(st_castToPoint(st_geomFromWKT(location))) from geotbl where id='6'

  • The query result is as follows:
    22°0'0.000\"N 11°0'0.000\"E

st_asText

String st_asText(Geometry geom)

This function returns Geometry geom in WKT representation.

st_geoHash

String st_geoHash(Geometry geom, Int prec)

This function returns the Geohash (in base-32 representation) of an interior point of Geometry geom. prec indicates the encoding precision. For more information about Geohash, see Geohash.

Example:

  • Query command:

    select st_geoHash(st_geomFromWKT(location),25) from geotbl where id='1'

  • The query result is as follows:
    ssf17