Share via


st_geomfromwkb function

Applies to: check marked yes Databricks Runtime 17.1 and above

Important

This feature is in Public Preview.

Parses the WKB description of a geometry and returns the corresponding GEOMETRY value. The SRID value of the returned GEOMETRY value is the value of the sridExpr if specified, or 0 otherwise.

Syntax

st_geomfromwkb ( wkbExpr[, sridExpr] )

Arguments

  • wkbExpr: A BINARY value, representing a geometry in WKB format.
  • sridExpr: An optional INTEGER value that is set to be the SRID of the returned GEOMETRY value.

Returns

A value of type GEOMETRY(srid) where srid is the value of sridExpr if sridExpr is a constant (foldable) expression, or GEOMETRY(ANY) otherwise. If sridExpr is omitted the type of the returned value is GEOMETRY(0). The returned value is the geometry corresponding to the input WKB description.

The function returns NULL if any of the inputs is NULL.

Error conditions

  • If the value of wkbExpr is an invalid WKB description, the function returns WKB_PARSE_ERROR.
  • If the value of sridExpr is unsupported, the function returns ST_INVALID_SRID_VALUE.

Examples

-- Simple example where we do not specify the output SRID. It defaults to 0. Input is in little-endian format.
> SELECT st_asewkt(st_geomfromwkb(X'01D1070000000000000000244000000000000041400000000000003740'))
  POINT M (10 34 23)

-- Simple example where we do not specify the output SRID. It defaults to 0. Input is in big-endian format.
> SELECT st_asewkt(st_geomfromwkb(X'00000007D1402400000000000040410000000000004037000000000000'))
  POINT M (10 34 23)

-- Simple example where we specify the SRID value for the output.
> SELECT st_asewkt(st_geomfromwkb(X'01D1070000000000000000244000000000000041400000000000003740', 3857))
  SRID-3857;POINT M (10 34 23)