[postgis-users] Building "reasonable" lines

Carlo A. Bertelli (Charta s.r.l.) carlo.bertelli at gmail.com
Fri Nov 11 09:30:25 PST 2011


Hello,
one of our project needs a series of linestrings that link points of
the same type. The data does not have any specific order, but the
lines should be simple (not tangled) and the points ordered by
proximity. Do you have any suggestion?

This is the query I use now, but it doesn't work.

SELECT  id_group, -- to have a numeric key
        groupname,
        MakeLine(wkb_geometry) AS geom
FROM (
	SELECT  e.id_group,
	        o.groupname,
	        e.survey_year,
	        g.wkb_geometry
	FROM test.monksandnuns AS e,
	     public.capoluoghi AS g,
	     test.regclrg_groups A o
	WHERE e.geo_code = g.istat_com
	AND   e.country = 'I'
	AND   e.groupname = o.denom_groupname
	GROUP BY g.ogc_fid, g.wkb_geometry, e.survey_year, o.id_group,
e.groupname, e.congregazione
	UNION -- we have two countries
	SELECT	e.id_group,
	        o.groupname,
	        e.survey_year,
	        wkb_geometry
	FROM test.monksandnuns AS e,
	     public.france_cheflf_m_l2_point_wgs AS g,
	     test.regclrg_groups AS o
	WHERE e.geo_code = g.depcom
	AND   e.country = 'F'
	AND   e.groupname = o.denom_groupname
	GROUP BY g.ogc_fid, g.wkb_geometry, e.survey_year, o.id_group,
e.groupname, e.congregazione
   ) AS sedi
WHERE survey_year = 1829
GROUP BY groupname, id_group
;

is there a way to obtain:
* a polyline for every group;
* simple line?

TIA
c



More information about the postgis-users mailing list