Skip to content

Instantly share code, notes, and snippets.

@pigreco
Last active November 23, 2019 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigreco/a4f60db10373013bc9738e4f6b835619 to your computer and use it in GitHub Desktop.
Save pigreco/a4f60db10373013bc9738e4f6b835619 to your computer and use it in GitHub Desktop.
-- Creo tabella
CREATE TABLE "tmp_lineMerge" AS
SELECT ROW_NUMBER() OVER(ORDER BY pk) AS RowNum,
ST_LineMerge(ST_Union(geom)) AS geom,
tipo,
count(*) as nro,
group_concat (pk) as pk_old -- occhio!!!
FROM "linee"
GROUP BY tipo
order by 3;
-- Ricovero la geometria
SELECT RecoverGeometryColumn('tmp_lineMerge','geom',3004,'Linestring','XY');
-- Dump geometria
SELECT ElementaryGeometries( 'tmp_lineMerge' ,
'geom' , 'lines_merge_tipo' ,'out_pk' , 'out_multi_id', 1 ) as num, 'lines' as label;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment