[Qgis-user] Fwd: Merging polygons leaves isolated lines

Alex Mandel tech_dev at wildintellect.com
Tue Apr 29 09:14:59 PDT 2014


On 01/19/2014 07:09 AM, Richard Duivenvoorde wrote:
> 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
> 

I can't see any of the original images or files posted of the issue, but
I assume this is topology related. Especially if the buffer solves it.

Other ways to get there:
v.clean in the GRASS part of the Processing toolbox, choose advanced and
set a tolerance <- it's similar to the buffer procedure.

Looking at Richard's output my guess is you need to start thinking about
using the topology tools either in QGIS, Postgis or GRASS.
Being a valid geometry and being topology valid are 2 different things
(topology does not allow overlap, overlapping regions become a 3rd
region of joint value).

Thanks,
Alex





More information about the Qgis-user mailing list