STV_GeometryPoint
Returns a GEOMETRY point, based on the input values.
This approach is the most-optimal way to convert raw coordinates to GEOMETRY points.
Behavior Type
Syntax
STV_GeometryPoint( x, y [, srid] )
Arguments
x |
x-coordinate or longitude, FLOAT. |
y
|
y-coordinate or latitude, FLOAT. |
srid
|
(Optional) Spatial Reference Identifier (SRID) assigned to the point, INTEGER. |
Returns
GEOMETRY
Examples
The following examples show how to use STV_GeometryPoint.
Return a GEOMETRY point with an SRID:
=> SELECT ST_AsText(STV_GeometryPoint(71.148562, 42.989374, 4326));
ST_AsText
-----------------------------
POINT (-71.148562 42.989374)
(1 row)
Return GEOMETRY points using two columns:
=> CREATE TABLE geom_data (id IDENTITY, x FLOAT, y FLOAT, SRID int); CREATE TABLE => COPY geom_data FROM STDIN; Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself. >> 42.36383053600048|-71.10165445099966|4326 >> 42.3670937980005|-71.10644448699964|4326 >> \. => SELECT id, ST_AsText(STV_GeometryPoint(x, y, SRID)) FROM geom_data; id | ST_AsText ----+------------------------------------ 1 | POINT (-71.101654451 42.363830536) 2 | POINT (-71.106444487 42.367093798) (2 rows)
Create GEOMETRY points by manipulating data source columns during load:
=> CREATE TABLE geom_data_load (id IDENTITY, geom GEOMETRY);
CREATE TABLE
=> COPY geom_data_load (lon FILLER FLOAT,
lat FILLER FLOAT,
geom AS STV_GeometryPoint(lon, lat))
FROM 'test_coords.csv' DELIMITER ',';
Rows Loaded
-------------
2
(1 row)
=> SELECT id, ST_AsText(geom) FROM geom_data_load;
id | ST_AsText
----+------------------------------------
1 | POINT (-75.101654451 43.363830536)
2 | POINT (-75.106444487 43.367093798)
(2 rows)