[Qgis-user] Fwd: Merging polygons leaves isolated lines
Richard Duivenvoorde
rdmailings at duif.net
Sun Jan 19 07:09:06 PST 2014
On 15-01-14 19:28, Lynkos wrote:
> Thanks Paolo for the rapid response. It does look as though my problem
> is related. Any guidance on how I can clean up the original shapefile?
> Sarah.
Hi Sarah,
I was curious what was happening here, and was questioning if it was a
QGIS fault, or a GEOS (the underlying lib which takes care of the
merging) one.
I loaded your shape in Postgis as table 'merge', and merged those geoms via:
insert into merge (id_0, id, geom)
VALUES (999, 999, (select ST_Multi(ST_UNION (geom)) from merge where
id_0 in (24,25,29)) )
but this looked exactly the same as your merged shape... (postgis also
uses GEOS :-) )...
So the problem is indeed:
http://lists.osgeo.org/pipermail/qgis-developer/2014-January/030119.html
looking into the docs of geos, there was talking about a buffer. Which
made me think about: what about adding (and later removing a small buffer).
So just before the merge, add a small buffer (1):
insert into merge (id_0, id, geom)
VALUES (999, 999, (select ST_Multi(ST_UNION (st_buffer(geom,1))) from
merge where id_0 in (24,25,29)) )
which then did NOT sow the artifacts anymore, but indeed is one meter
too big.
So now a negative buffer (-1) over that one:
insert into merge (id_0, id, geom)
VALUES (9999, 9999, (select ST_Multi(st_buffer(geom,-1)) from merge
where id_0 = 999))
And I think you have what you want...
http://www.flickr.com/photos/97361298@N07/12031619434/
http://www.flickr.com/photos/97361298@N07/12031256205/
Off course this can give other artifacts sometimes (because you are
actually merging the buffered geometries), but I think it is better then
a normal merge...
It's pretty easy to do this in postgis, but can probably also been done
via processing?
Regards,
Richard
More information about the Qgis-user
mailing list