Spatial constructor functions can be used to obtain binary representations of the POINT, LINE, or POLYGON GEOMETRY data types. You can also use these functions to convert binary data to text and obtain binary values for geometry data that is expressed as Well-Known Text (WKT).

  • ST_Point: uses the result of x/y as a coordinate to construct a point value. x and y are two numerical values of the DOUBLE type.
  • ST_AsText: returns data in the WKT format.
  • ST_GeometryFromText or ST_GeomFromText: converts text in the WKT format into a geometry data type.
  • ST_IsValidWKT: returns a BOOLEAN value that indicates whether the text is well-formed in the WKT format.
  • ST_LineFromText: returns a LineString object by using its WKT representation.
  • ST_PointFromText: returns a PointString object by using its WKT representation.
  • ST_PolygonFromText: returns a PolygonString object by using its WKT representation.
  • ST_LineString: returns a LineString geometry object formed from an array of points.
  • ST_MultiPoint: returns a MultiPoint geometry object formed from an array of points.
  • ST_GeomFromBinary: returns a geometry object from a WKB type object.
  • geometry_from_hadoop_shape: returns a geometry object from a Spatial Framework for Hadoop type object.
  • to_spherical_geography: returns a spherical geography object from a geometry object. This converts an identifier defined in 2D space to that defined in 3D space.
  • to_geometry: returns a geometry object from a spherical geography object. In fact, each geography object is a reasonable geometry object.
  • ST_AsBinary: returns a VARBINARY data type that contains the WKB representation of g1.
  • ST_Buffer: returns all the points whose distance from g1 is less than or equal to d.

ST_Point

ST_Point(x, y)
  • Description: This function uses the result of x/y as a coordinate to construct a point value. x and y are two numerical values of the DOUBLE type.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_Point(1,1);
    +-----------------------+
    | ST_Point(1,1)         |
    +-----------------------+
    |        �?      �?   |                    

ST_AsText

ST_AsText(geometry)
  • Description: This function converts each of the specified geometry data types to text.
  • Return value type: WKT.
  • Example:
    SELECT ST_AsText(ST_Point(1,1));
    +--------------------------+
    | ST_AsText(ST_Point(1,1)) |
    +--------------------------+
    | POINT (1 1)              |                   

ST_GeometryFromText or ST_GeomFromText

ST_GeometryFromText(wkt)
  • Description: This function uses a WKT-formatted string to construct a value of the GEOMETRY type.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_GeometryFromText('Point(1 1)');
    +-----------------------------------+
    | ST_GeometryFromText('Point(1 1)') |
    +-----------------------------------+
    |        �?      �?                 |              
    SELECT ST_AsText(ST_GeometryFromText('Point(1 1)'));
    +----------------------------------------------+
    | ST_AsText(ST_GeometryFromText('Point(1 1)')) |
    +----------------------------------------------+
    | POINT (1 1)                                  |          

ST_IsValidWKT

ST_IsValidWKT(wkt)
  • Description: This function returns a BOOLEAN value that indicates whether the text is well-formed in the WKT format.
  • Return value type: BOOLEAN.
  • Example:
    SELECT ST_IsValidWKT('MULTIPOINT (1 2, 2 4, 3 6, 4 8)');
    +-------------------------------------------------------------+
    |        ST_IsValidWKT('MULTIPOINT (1 2, 2 4, 3 6, 4 8)')     |
    +-------------------------------------------------------------+
    |                        true                                 |

ST_LineFromText

ST_LineFromText(wkt)
  • Description: This function returns a LineString object by using its WKT representation.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_LineFromText('LINESTRING (1 1, 2 2, 1 3)');
    +-------------------------------------------------------------+
    |        ST_LineFromText('LINESTRING (1 1, 2 2, 1 3)')        |
    +-------------------------------------------------------------+
    |                         �?      �?                          |
    SELECT ST_AsText(ST_LineFromText('LINESTRING (1 1, 2 2, 1 3)'));
    +-----------------------------------------------------------------------+
    |        ST_AsText(ST_LineFromText('LINESTRING (1 1, 2 2, 1 3)'))       |
    +-----------------------------------------------------------------------+
    |                        LINESTRING (1 1, 2 2, 1 3)                     |

ST_PointFromText

ST_PointFromText(wkt)
  • Description: This function returns a PointString object by using its WKT representation.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_PointFromText('POINT (1 2)');
    +-------------------------------------------------------------+
    |        ST_PointFromText('POINT (1 2)')                      |
    +-------------------------------------------------------------+
    |                         �?      �?                          |
    SELECT ST_AsText(ST_PointFromText('POINT (1 2)'));
    +-------------------------------------------------------------+
    |        ST_AsText(ST_PointFromText('POINT (1 2)'))           |
    +-------------------------------------------------------------+
    |                       POINT (1 2)                           |

ST_PolygonFromText

ST_PolygonFromText(wkt)
  • Description: This function returns a PolygonString object by using its WKT representation.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_PolygonFromText('POLYGON ((1 1, 1 4, 4 4, 4 1))');
    +-------------------------------------------------------------+
    |        ST_PolygonFromText('POLYGON ((1 1, 1 4, 4 4, 4 1))') |
    +-------------------------------------------------------------+
    |                         �?      �?                          |
    SELECT ST_AsText(ST_PolygonFromText('POLYGON ((1 1, 1 4, 4 4, 4 1))'));
    +------------------------------------------------------------------------+
    |        ST_AsText(ST_PolygonFromText('POLYGON ((1 1, 1 4, 4 4, 4 1))')) |
    +------------------------------------------------------------------------+
    |                        POLYGON ((1 1, 1 4, 4 4, 4 1))                  | 

ST_LineString

ST_LineString(array(g1,g2...))
  • Description: This function returns a LineString geometry object formed from an array of points.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_LineString(array[ST_Point(1,2), ST_Point(3,4)]));
    +------------------------------------------------------------------------+
    | ST_AsText(ST_LineString(array[ST_Point(1,2), ST_Point(3,4)]))          |
    +------------------------------------------------------------------------+
    |           LINESTRING (1 2, 3 4)                                        |    

ST_MultiPoint

ST_MultiPoint(array(g1,g2...))
  • Description: This function returns a MultiPoint geometry object formed from an array of points.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_MultiPoint(array[ST_GeometryFromText('POINT(1 2)'), ST_GeometryFromText('POINT (3 4)]')));
    +----------------------------------------------------------------------------------------------------------------------+
    |  ST_AsText(ST_MultiPoint(array[ST_GeometryFromText('POINT(1 2)'), ST_GeometryFromText('POINT (3 4)]')) )   |
    +----------------------------------------------------------------------------------------------------------------------+
    |          MULTIPOINT ((1 2), (3 4))                                                                                   | 

ST_GeomFromBinary

ST_GeomFromBinary(wkb)
  • Description: This function returns a geometry object from a WKB type object.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_GeomFromBinary(ST_AsBinary(ST_GeometryFromText('MULTIPOINT ((1 2), (3 4)')))));
    +----------------------------------------------------------------------------------------------------------------------+
    |  ST_AsText(ST_GeomFromBinary(ST_AsBinary(ST_GeometryFromText('MULTIPOINT ((1 2), (3 4)')))))                         |
    +----------------------------------------------------------------------------------------------------------------------+
    |          MULTIPOINT ((1 2), (3 4))                                                                                   |

geometry_from_hadoop_shape

geometry_from_hadoop_shape(wkb)
  • Description: This function returns a geometry object from a Spatial Framework for Hadoop type object.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(geometry_from_hadoop_shape(from_hex('000000000101000000000000000000F03F0000000000000040')));
    +-------------------------------------------------------------------------------------------------------+
    | ST_AsText(geometry_from_hadoop_shape(from_hex('000000000101000000000000000000F03F0000000000000040'))) |
    +-------------------------------------------------------------------------------------------------------+
    |          MULTIPOINT ((1 2), (3 4))                                                                    |

to_spherical_geography

to_spherical_geography(g1)
  • Description: This function returns a spherical geography object from a geometry object. This converts an identifier defined in 2D space to that defined in 3D space.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT to_spherical_geography(ST_Point(-71.0882, 42.3607));
    +-----------------------------------------------------------+
    | to_spherical_geography(ST_Point(-71.0882, 42.3607))       |
    +-----------------------------------------------------------+
    |          �?      �?                                       |

to_geometry

to_geometry(g1)
  • Description: This function returns a geometry object from a spherical geography object. In fact, each geography object is a reasonable geometry object.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT to_geometry(to_spherical_geography(ST_Point(61.56, -158.54)));
    +----------------------------------------------------------------------+
    | SELECT to_geometry(to_spherical_geography(ST_Point(61.56, -158.54))) |
    +----------------------------------------------------------------------+
    |           �?      �?                                                 |

ST_AsBinary

ST_AsBinary(g1)
  • Description: This function returns a VARBINARY data type that contains the WKB representation of g1.
  • Return value type: VARBINARY.
  • Example:
    SELECT ST_AsText(ST_GeomFromBinary(ST_AsBinary(ST_GeometryFromText('MULTIPOINT ((1 2), (3 4)')))));
    +----------------------------------------------------------------------------------------------------------------------+
    |  ST_AsText(ST_GeomFromBinary(ST_AsBinary(ST_GeometryFromText('MULTIPOINT ((1 2), (3 4)')))))                         |
    +----------------------------------------------------------------------------------------------------------------------+
    |          MULTIPOINT ((1 2), (3 4))                                                                                   |

ST_Buffer

ST_Buffer(g1, d)
  • Description: This function returns all the points whose distance from g1 is less than or equal to d.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_Buffer(ST_Point(0, 0), 0.5));
    +-------------------------------------------------------------------+
    |  ST_AsText(ST_Buffer(ST_Point(0, 0), 0.5))                        |
    +-------------------------------------------------------------------+
    |          POLYGON ((0.5 0, 0.4989294616193014 0.03270156461507146, 
    0.49572243068690486 0.0652630961100257, 0.4903926402016149 0.09754516100806403,
    0.4829629131445338 0.12940952255126026, 0.47346506474755257 0.16071973265158065, 
    0.46193976625564315 0.19134171618254472, 0.4484363707663439 0.22114434510950046, 
    0.43301270189221913 0.2499999999999998, 0.41573480615127245 0.2777851165098009, 
    0.39667667014561747 0.30438071450436016, 0.3759199037394886 0.32967290755003426, 
    0.3535533905932737 0.3535533905932736, 0.32967290755003437 0.3759199037394886, 
    0.3043807145043603 0.39667667014561747, 0.2777851165098011 0.4157348061512725, 
    0.24999999999999997 0.43301270189221924, 0.22114434510950062 0.4484363707663441, 
    0.19134171618254486 0.4619397662556433, 0.16071973265158077 0.4734650647475528, 
    0.12940952255126037 0.48296291314453416, 0.09754516100806412 0.4903926402016152, 
    0.06526309611002579 0.4957224306869052, 0.03270156461507153 0.49892946161930174, 
    0 0.5, -0.03270156461507146 0.4989294616193014, -0.0652630961100257 
    0.49572243068690486, -0.09754516100806403 0.4903926402016149, -0.12940952255126026 
    0.4829629131445338, -0.16071973265158065 0.47346506474755257, -0.19134171618254472 
    0.46193976625564315, -0.22114434510950046 0.4484363707663439, -0.2499999999999998 
    0.43301270189221913, -0.2777851165098009 0.41573480615127245, -0.30438071450436016 
    0.39667667014561747, -0.32967290755003426 0.3759199037394886, -0.3535533905932736 
    0.3535533905932737, -0.3759199037394886 0.32967290755003437, -0.39667667014561747 
    0.3043807145043603, -0.4157348061512725 0.2777851165098011, -0.43301270189221924 
    0.24999999999999997, -0.4484363707663441 0.22114434510950062, -0.4619397662556433 
    0.19134171618254486, -0.4734650647475528 0.16071973265158077, -0.48296291314453416 
    0.12940952255126037, -0.4903926402016152 0.09754516100806412, -0.4957224306869052 
    0.06526309611002579, -0.49892946161930174 0.03270156461507153, -0.5 0, 
    -0.4989294616193014 -0.03270156461507146, -0.49572243068690486 -0.0652630961100257, 
    -0.4903926402016149 -0.09754516100806403, -0.4829629131445338 -0.12940952255126026, 
    -0.47346506474755257 -0.16071973265158065, -0.46193976625564315 
    -0.19134171618254472, -0.4484363707663439 -0.22114434510950046, 
    -0.43301270189221913 -0.2499999999999998, -0.41573480615127245 -0.2777851165098009, 
    -0.39667667014561747 -0.30438071450436016, -0.3759199037394886 -0.32967290755003426, 
    -0.3535533905932737 -0.3535533905932736, -0.32967290755003437 -0.3759199037394886, 
    -0.3043807145043603 -0.39667667014561747, -0.2777851165098011 -0.4157348061512725, 
    -0.24999999999999997 -0.43301270189221924, -0.22114434510950062 -0.4484363707663441, 
    -0.19134171618254486 -0.4619397662556433, -0.16071973265158077 -0.4734650647475528, 
    -0.12940952255126037 -0.48296291314453416, -0.09754516100806412 -0.4903926402016152, 
    -0.06526309611002579 -0.4957224306869052, -0.03270156461507153 -0.49892946161930174, 
    0 -0.5, 0.03270156461507146 -0.4989294616193014, 0.0652630961100257 
    -0.49572243068690486, 0.09754516100806403 -0.4903926402016149, 0.12940952255126026 
    -0.4829629131445338, 0.16071973265158065 -0.47346506474755257, 0.19134171618254472 
    -0.46193976625564315, 0.22114434510950046 -0.4484363707663439, 0.2499999999999998 
    -0.43301270189221913, 0.2777851165098009 -0.41573480615127245, 0.30438071450436016 
    -0.39667667014561747, 0.32967290755003426 -0.3759199037394886, 0.3535533905932736 
    -0.3535533905932737, 0.3759199037394886 -0.32967290755003437, 0.39667667014561747 
    -0.3043807145043603, 0.4157348061512725 -0.2777851165098011, 0.43301270189221924 
    -0.24999999999999997, 0.4484363707663441 -0.22114434510950062, 0.4619397662556433 
    -0.19134171618254486, 0.4734650647475528 -0.16071973265158077, 0.48296291314453416 
    -0.12940952255126037, 0.4903926402016152 -0.09754516100806412, 0.4957224306869052 
    -0.06526309611002579, 0.49892946161930174 -0.03270156461507153, 0.5 0))                                |