ST_GEOGFROMGEOJSON
Constructs a GEOGRAPHY
object from a GeoJSON string.
The GeoJSON standard specifies that GeoJSON points are WGS 84 coordinates, and GeoJSON line segments are planar edges, meaning straight cartesian lines. However, contrary to that, in Firebolt, the line segments are interpreted as geodesic arcs.
The following image shows an extreme case of the difference between these. Both lines show the LineString from the GeoJSON string {"coordinates": [[-0.12457505963581639,51.5006710219584],[-74.04448100812115,40.68923977267272]],"type": "LineString"}
that connect the Statue of Liberty in New York City and Big Ben in London. The gray line represents the LineString as a straight Cartesian line, following the GeoJSON standard. In contrast, the red line interprets the LineString as a geodesic arc, consistent with Firebolt’s approach.
Syntax
ST_GEOGFROMGEOJSON(<GeoJSON>)
Parameters
Parameter | Description | Supported input types |
---|---|---|
<GeoJSON> | GeoJSON text representing the GEOGRAPHY object. | TEXT |
Return Type
ST_GEOGFROMGEOJSON
returns a value of type GEOGRAPHY
.
Example
The following code example constructs a Point from a GeoJSON string describing a Point at specified longitude and latitude coordinates and converts it to WKT format:
SELECT ST_ASTEXT(ST_GEOGFROMGEOJSON('{"type":"Point","coordinates":[-73.98551041593687,40.75793403395676]}')) AS result
Returns
result (TEXT) |
---|
‘POINT(-73.98551041593687 40.75793403395676)’ |