Describes the Firebolt implementation of the GEOGRAPHY
data type
GEOGRAPHY
data type.
GEOGRAPHY
data type represents geospatial data on the earth’s surface. It represents Points, LineStrings, Polygons, or combinations of these. Points in Firebolt’s GEOGRAPHY
data type represent points on the WGS84 reference spheroid (SRID 4326). All edges between points in LineStrings and Polygons are geodesics, meaning they represent the shortest path between points along the Earth’s curvature. Functions that use the GEOGRAPHY
data type model the Earth as a sphere with a radius of 6,371,008 meters.
GEOGRAPHY
types, with examples provided in the Well-Known Text (WKT) format for spatial data representation:
POINT (1 2)
LINESTRING (1 2, 3 4, 5 6)
POLYGON ((0 0 ,4 0 ,4 4 ,0 4 ,0 0 ), (1 1 ,2 1 ,2 2 ,1 2 ,1 1 )
MULTIPOINT ((0 0), (1 2))
MULTILINESTRING ((0 0,1 1,1 2), (2 3,3 2,5 4))
MULTIPOLYGON (((1 5, 5 5, 5 1, 1 1, 1 5)), ((6 5, 9 1, 6 1, 6 5)))
GEOMETRYCOLLECTION (POINT(2 3), LINESTRING(2 3, 3 4))
GEOGRAPHY
from the industry standard GeoJSON, Well-Known Text (WKT), and Well-Known Binary (WKB) representations, as well as the extended formats EWKT and EWKB introduced by the PostGIS extension. See the corresponding function documentations for further detail.
GEOGRAPHY
object from a string by using the GEOGRAPHY
prefix in a query, as shown in the following code example:
GEOGRAPHY
literals are automatically decoded based on the encoding format used. Supported formats include:
For more information, refer to Cast from TEXT.
Examples
You can use any supported format to create a GEOGRAPHY
object. The following examples demonstrate how to create the same GEOGRAPHY
object representing a Point at longitude -73.98551041593687 and latitude 40.75793403395676 using WKT, GeoJSON, and EWKB formats:
BYTEA
to GEOGRAPHY
behaves exactly like the ST_GEOGFROMWKB function.
GEOGRAPHY
to BYTEA
behaves exactly like the ST_ASEWKB function.
TEXT
to GEOGRAPHY
automatically detects the decoding used and supports the Extended Well-Known Text (EWKT), GeoJSON, and hex-encoded Extended Well-Known Binary (EWKB) formats. It behaves exactly like ST_GEOGFROMTEXT for Well-Known Text (WKT) inputs, like ST_GEOGFROMGEOJSON for GeoJSON inputs, and like ST_GEOGFROMWKB(DECODE(input, ‘HEX’)) for hex-encoded Well-Known Binary (WKB) inputs.
GEOGRAPHY
to TEXT
returns the hexadecimal representation of the output of the ST_ASEWKB function in upper case letters.
GEOGRAPHY
objects perform a process called snapping on their inputs. During snapping, any points of the inputs objects that are less than 1 micrometer apart from each other are moved to be exactly the same. For example, this means that a Point that is less than 1 micrometer away from a Polygon is treated as being on the Polygon’s boundary and two Polygons that are separated by less than 1 micrometer are treated as intersecting.
GEOGRAPHY
data type cannot be compared. This means that ORDER BY
or comparison operators are not supported on GEOGRAPHY
columns.
This also means that GEOGRAPHY
columns cannot be used in GROUP BY
clauses because they cannot be compared for equality.
GEOGRAPHY
data type: