ST_MakeLine — Cria uma Linestring de ponto, multiponto ou linha das geometrias.
geometry ST_MakeLine(
geometry geom1, geometry geom2)
;
geometry ST_MakeLine(
geometry[] geoms_array)
;
geometry ST_MakeLine(
geometry set geoms)
;
Creates a LineString containing the points of Point, MultiPoint, or LineString geometries. Other geometry types cause an error.
Variant 1: accepts two input geometries
Variant 2: accepts an array of geometries
Variant 3: aggregate function accepting a rowset of geometries. To ensure the order of the input geometries use ORDER BY
in the function call, or a subquery with an ORDER BY
clause.
Repeated nodes at the beginning of input LineStrings are collapsed to a single point. Repeated points in Point and MultiPoint inputs are not collapsed. ST_RemoveRepeatedPoints can be used to collapse repeated points from the output LineString.
This function supports 3d and will not drop the z-index.
Disponibilidad: 2.0.0 - Suporte para elementos de entrada linestring foi introduzido
Disponibilidad: 2.0.0 - Suporte para elementos de entrada linestring foi introduzido
Disponibilidade: 1.4.0 - ST_MakeLine(geomarray) foi introduzida. A ST_MakeLine agrega funções que foram melhoradas para lidar com mais pontos mais rápido.
Create a line composed of two points.
SELECT ST_AsText( ST_MakeLine(ST_Point(1,2), ST_Point(3,4)) ); st_astext --------------------- LINESTRING(1 2,3 4)
Cria uma CAIXA2D definida pelos pontos 2 3D dados das geometrias.
SELECT ST_AsEWKT( ST_MakeLine(ST_MakePoint(1,2,3), ST_MakePoint(3,4,5) )); st_asewkt ------------------------- LINESTRING(1 2 3,3 4 5)
Cria uma Linestring de ponto, multiponto ou linha das geometrias.
select ST_AsText( ST_MakeLine( 'LINESTRING(0 0, 1 1)', 'LINESTRING(2 2, 3 3)' ) ); st_astext ----------------------------- LINESTRING(0 0,1 1,2 2,3 3)
Create a line from an array formed by a subquery with ordering.
SELECT ST_MakeLine( ARRAY( SELECT ST_Centroid(geom) FROM visit_locations ORDER BY visit_time) );
Create a 3D line from an array of 3D points
SELECT ST_AsEWKT( ST_MakeLine( ARRAY[ ST_MakePoint(1,2,3), ST_MakePoint(3,4,5), ST_MakePoint(6,6,6) ] )); st_asewkt ------------------------- LINESTRING(1 2 3,3 4 5,6 6 6)
Esse exemplo pega uma sequência de pontos do GPS e cria um relato para cada torre gps onde o campo geométrico é uma line string composta com os pontos do gps na ordem da viagem.
Using aggregate ORDER BY
provides a correctly-ordered LineString.
SELECT gps.track_id, ST_MakeLine(gps.geom ORDER BY gps_time) As geom FROM gps_points As gps GROUP BY track_id;
Prior to PostgreSQL 9, ordering in a subquery can be used. However, sometimes the query plan may not respect the order of the subquery.
SELECT gps.track_id, ST_MakeLine(gps.geom) As geom FROM ( SELECT track_id, gps_time, geom FROM gps_points ORDER BY track_id, gps_time ) As gps GROUP BY track_id;
ST_RemoveRepeatedPoints, ST_AsText, ST_GeomFromText, ST_MakePoint