[Qgis-user] "Dissolve" a line layer?
Jake Maier
j.m at jmforestry.com
Fri Jun 8 15:22:10 PDT 2012
From: qgis-user-bounces at lists.osgeo.org [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Micha Silver
Sent: Friday, June 08, 2012 3:13 PM
To: magerlin
Cc: qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] "Dissolve" a line layer?
On 08/06/2012 09:30, magerlin wrote:
I've got a road network which is broken down to a lot of very short sections.
Theese I would like to join by the road name to just get one feature per
road name.
If it had been a polygon layer I could have used the Vector - Geoprocessing
- Dissolve tool, but it is only for polygons.
I am aware that I can do it manually either 2 sections at a time by the
"Join two lines" plugin or more sections at a time by using the "Merge
selected features" button in the Advanced Digitizing toolbar. But there are
far to many sections to do this by hand....
Any suggestions?
If you're willing to work with spatialite, then you can do this with a query as follows:
(Assuming you have a roads shape file, with columns "road_id", and "road_name")
spatialite> .loadshp roads.shp roads LATIN1 4326
spatialite> CREATE TABLE roads_merged (road_id integer primary key, road_name text);
spatialite> SELECT AddGeometryColumn('roads_merged', 'Geometry', 4326, 'MULTILINESTRING', 'XY');
spatialite> INSERT INTO roads_merged (road_id, road_name, Geometry)
SELECT road_id, road_name, CastToMulti(GUnion(Geometry))
FROM roads
GROUP BY road_name;
The first line loads a shapefile into spatialite, with LATIN1 encoding and EPSG code 4326 (Lon/Lat WGS84)
The second creates a new empty table for the merged roads, and the third makes this new table spatial, accepting geometry types MULTILINESTRING, and also EPSG 4326.
The last line, the INSERT uses GROUP BY to merge the rows from the original table with the same road name. And the GUnion() function merges the line segment's geometry into MULTILINESTRING features. (CastToMulti to make sure...)
Give it a try,
Micha
-----
Regards Morten
Qgis 1.7.4 Stand alone installer in Win7 64 bit
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Dissolve-a-line-layer-tp4979880.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.
_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user
This mail was received via Mail-SeCure System.
[JM] I just installed spacialite and I’m very intrigued by what you did there, Micha, but now my question.
Where can I read up on all the commands for spacialite? What’s the best way to learn all that stuff J
Thanks
Jake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20120608/df778c83/attachment.html>
More information about the Qgis-user
mailing list