1 Sep 2009 01:32
Re: union/merge huge river dataset into single lines group by name
Kevin Neufeld <kneufeld <at> refractions.net>
2009-08-31 23:32:45 GMT
2009-08-31 23:32:45 GMT
The below queries should group together all rivers with the same name into a MULTILINESTRING geometry. Since you are using LineMerge, degree 2 nodes, are removed from every collection. The subsequent query will expand the collections back to individual linestrings so that disjoint lines (or lines that meet at confluences greater than 2) remain intact. This is assuming of course that your dataset is properly noded. If you have cases where rivers cross or where they intersect at vertices other than their endpoints and you want to treat these as one feature, use ST_Union instead of ST_LineMerge. -- creates MULTILINESTRING per river name CREATE TABLE merged_rivers AS SELECT river_name, ST_Multi(ST_LineMerge(ST_Collect(the_geom))) AS geom FROM my_river_table GROUP BY river_name -- explodes the MULTILINESTRING into separate LINESTRINGs SELECT river_name, (ST_Dump(geom)).geom FROM merged_rivers; Hope that helps, Kevin karsten vennemann wrote: > PostGIS users, > > I was researching how to effectively merge river segments in a really > huge river dataset that have the same name and touch each other (share a(Continue reading)
RSS Feed