A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/to_geometry below:

Website Navigation


TO_GEOMETRY | Snowflake Documentation

TO_GEOMETRY

Parses an input and returns a value of type GEOMETRY.

See also:

TRY_TO_GEOMETRY , ST_GEOMETRYFROMWKB , ST_GEOMETRYFROMWKT

Syntax

Use one of the following:

TO_GEOMETRY( <varchar_expression> [ , <srid> ] [ , <allow_invalid> ] )

TO_GEOMETRY( <binary_expression> [ , <srid> ] [ , <allow_invalid> ] )

TO_GEOMETRY( <variant_expression> [ , <srid> ] [ , <allow_invalid> ] )

TO_GEOMETRY( <geography_expression> [ , <srid> ] [ , <allow_invalid> ] )

Copy

Arguments

Required:

varchar_expression

The argument must be a string expression that represents a valid geometric object in one of the following formats:

binary_expression

The argument must be a binary expression in WKB or EWKB format.

variant_expression

The argument must be an OBJECT in GeoJSON format.

geography_expression

The argument must be an expression of type GEOGRAPHY.

Optional:

srid

The integer value of the SRID to use.

allow_invalid

If TRUE, specifies that the function should return a GEOGRAPHY or GEOMETRY object, even when the input shape is invalid and cannot be repaired. For details, refer to Specifying how invalid geospatial shapes are handled.

Returns

The function returns a value of type GEOMETRY.

Usage notes Examples

The following example shows how to use the TO_GEOMETRY function to convert an object represented in WKT to a GEOMETRY object. The example does not specify the srid argument, and the SRID is not specified in the input representation of the object, so the SRID is set to 0.

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT TO_GEOMETRY('POINT(1820.12 890.56)');

Copy

+--------------------------------------+
| TO_GEOMETRY('POINT(1820.12 890.56)') |
|--------------------------------------|
| SRID=0;POINT(1820.12 890.56)         |
+--------------------------------------+

The following example converts an object represented in EWKT to a GEOMETRY object. The input EKWT specifies the SRID to use:

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT TO_GEOMETRY('SRID=4326;POINT(1820.12 890.56)');

Copy

+------------------------------------------------+
| TO_GEOMETRY('SRID=4326;POINT(1820.12 890.56)') |
|------------------------------------------------|
| SRID=4326;POINT(1820.12 890.56)                |
+------------------------------------------------+

The following example demonstrates how to specify the SRID as the srid input argument:

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT TO_GEOMETRY('POINT(1820.12 890.56)', 4326);

Copy

+--------------------------------------------+
| TO_GEOMETRY('POINT(1820.12 890.56)', 4326) |
|--------------------------------------------|
| SRID=4326;POINT(1820.12 890.56)            |
+--------------------------------------------+

The following example returns the GEOMETRY object for a geospatial object with a Z coordinate described in EWKT format:

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';

SELECT TO_GEOMETRY('SRID=32633;POINTZ(389866.35 5819003.03 30)');

Copy

+-----------------------------------------------------------+
| TO_GEOMETRY('SRID=32633;POINTZ(389866.35 5819003.03 30)') |
|-----------------------------------------------------------|
| SRID=32633;POINTZ(389866.35 5819003.03 30)                |
+-----------------------------------------------------------+

For examples that convert a GEOGRAPHY object to a GEOMETRY object, see Converting between GEOGRAPHY and GEOMETRY.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4