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

2014-04-29 Thread Alex Mandel
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 (, , (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


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-01-19 Thread Richard Duivenvoorde
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 (, , (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



___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-01-16 Thread Lynkos
Thanks to everyone for the help and suggestions so far. I've uploaded all
the shapefile parts here (sorry, yesterday I was in a rush and I just
wasn't thinking):

https://www.dropbox.com/s/ru4s3bi2bt5z4c2/QGIS-merge.zip

This file is the result of several save-as operations, so the problem
outlined by Paolo could be a factor. But I've also tried with the original
shape file (which should be as drawn) and it behaves in exactly the same
way.

Thanks again, Sarah.



2014/1/16 Tim Sutton li...@linfiniti.com

 HI Sarah

 Can you post all the parts of the shapefile that others may test (.shp
 alone is not enough we need .dbf and .shx too).

 Regards

 Tim

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

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

2014-01-15 Thread Lynkos
I've been given a shape file representing a vegetation map which I now have
to modify, merging a number of polygons. When I do this, in almost all
cases the merge leaves a number of lines, either attached to one of the
polygons or completely isolated. An example of the problem (one of the
worst) is illustrated in the following screenshots.

Firstly a section of the shape:
https://www.dropbox.com/s/amik6g9cdoqg84b/Screenshot%202014-01-15%2017.42.18.jpg

The three polygons to be merged selected:
https://www.dropbox.com/s/6gl83y2jwgxvrje/Screenshot%202014-01-15%2017.42.33.jpg

The section of the shape after the merge:
https://www.dropbox.com/s/f1iem85kidkwkwx/Screenshot%202014-01-15%2017.42.53.jpg

And a close-up of the unattached lines left after the operation:
https://www.dropbox.com/s/i4rmyi7apcfpgg9/Screenshot%202014-01-15%2017.44.05.jpg

In case it is relevant, here are my snap options:
https://www.dropbox.com/s/73ky3qgbzk16esj/Screenshot%202014-01-15%2017.44.30.jpg

And here is a part of the shape file:
https://www.dropbox.com/s/n2asd9urvyd5fc8/merge-test.shp

If I had just a few polygons to merge, I could simply eliminate the lines,
but the file contains about 500, a large proportion of which must be
merged. I imagine the problem is caused by errors in the original polygons,
but the errors don't show up on either visual examination or using the
verify validity function.
Any ideas on what the problem might be and how to resolve it, if possible,
eliminating it at the roots by correcting the original shape?
Thanks, Sarah.

P.S. Let me know if you have problems visualizing the images or downloading
the file.


-- 
*Sarah Gregg*
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

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

2014-01-15 Thread Paolo Cavallini
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Il 15/01/2014 18:17, Lynkos ha scritto:
 I've been given a shape file representing a vegetation map which I now have to
 modify, merging a number of polygons. When I do this, in almost all cases the 
 merge
 leaves a number of lines, either attached to one of the polygons or completely
 isolated. An example of the problem (one of the worst) is illustrated in the
 following screenshots. 

Hi Lynkos,
I think this is another side of this issue:
http://lists.osgeo.org/pipermail/qgis-developer/2014-January/030119.html
Contributions welcome.
All the best.

- -- 
Paolo Cavallini - www.faunalia.eu
Corsi QGIS e PostGIS: http://www.faunalia.eu/training.html
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iEYEARECAAYFAlLWzVIACgkQ/NedwLUzIr5FfACfQ8GfFPlfFw+gCN5Qnb5609wR
s7sAn3iGkHiGWCZlEoLxE+5f7/5GgY4q
=qUQR
-END PGP SIGNATURE-
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-01-15 Thread Lynkos
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.


2014/1/15 Paolo Cavallini cavall...@faunalia.it

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Il 15/01/2014 18:17, Lynkos ha scritto:
  I've been given a shape file representing a vegetation map which I now
 have to
  modify, merging a number of polygons. When I do this, in almost all
 cases the merge
  leaves a number of lines, either attached to one of the polygons or
 completely
  isolated. An example of the problem (one of the worst) is illustrated in
 the
  following screenshots.

 Hi Lynkos,
 I think this is another side of this issue:
 http://lists.osgeo.org/pipermail/qgis-developer/2014-January/030119.html
 Contributions welcome.
 All the best.

 - --
 Paolo Cavallini - www.faunalia.eu
 Corsi QGIS e PostGIS: http://www.faunalia.eu/training.html
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1
 Comment: Using GnuPG with Icedove - http://www.enigmail.net/

 iEYEARECAAYFAlLWzVIACgkQ/NedwLUzIr5FfACfQ8GfFPlfFw+gCN5Qnb5609wR
 s7sAn3iGkHiGWCZlEoLxE+5f7/5GgY4q
 =qUQR
 -END PGP SIGNATURE-
 ___
 Qgis-user mailing list
 Qgis-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-user




-- 
*Sarah Gregg*
immagini - parole - territorio - natura
Web: www.wild-eyes.eu
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

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

2014-01-15 Thread Richard Duivenvoorde
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 All,

People from the Technical University Delft have created an automated way
for: Validation and Automatic Repair of Planar Partitions. It is
called 'pprepair'.

I'm not 100% sure it fixes your problem, but as a commandline tool it is
pretty easy to run.

It's pure c++ but has cgal as dependency. On debian it was 2 minutes to
build and run.

Code is here:
https://github.com/tudelft-gist/pprepair

Some theory:
http://www.gdmc.nl/ken/files/12_osgis.pdf

And Barry blogging about it:
http://geospaced.blogspot.nl/2012/09/fixing-polygons-with-pprepair.html

If interesting, have it a go.

Regards,

Richard Duivenvoorde

ps actually I promised the TU people to write a simple qgis plugin for
calling it in a separate process (like we do with gdal commands), so if
you are on it.

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-01-15 Thread Paolo Cavallini
Il 15/01/2014 21:06, Richard Duivenvoorde ha scritto:
 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 All,
 
 People from the Technical University Delft have created an automated way
 for: Validation and Automatic Repair of Planar Partitions. It is
 called 'pprepair'.
 
 I'm not 100% sure it fixes your problem, but as a commandline tool it is
 pretty easy to run.
 
 It's pure c++ but has cgal as dependency. On debian it was 2 minutes to
 build and run.
 
 Code is here:
 https://github.com/tudelft-gist/pprepair
 
 Some theory:
 http://www.gdmc.nl/ken/files/12_osgis.pdf
 
 And Barry blogging about it:
 http://geospaced.blogspot.nl/2012/09/fixing-polygons-with-pprepair.html
 
 If interesting, have it a go.
 
 Regards,
 
 Richard Duivenvoorde
 
 ps actually I promised the TU people to write a simple qgis plugin for
 calling it in a separate process (like we do with gdal commands), so if
 you are on it.

good stuff! a Processing provider would be much welcome. The
availability of packages for many platforms will be the limiting factor
for its spread, however. Do you know if the authors have plans to
package it for e.g. Debian and OSGeo4W?
Thanks.

-- 
Paolo Cavallini - www.faunalia.eu
QGIS  PostGIS courses: http://www.faunalia.eu/training.html
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


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

2014-01-15 Thread Tim Sutton
HI Sarah

Can you post all the parts of the shapefile that others may test (.shp
alone is not enough we need .dbf and .shx too).

Regards

Tim


On Wed, Jan 15, 2014 at 8:28 PM, Lynkos lynkosm...@gmail.com 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.


 2014/1/15 Paolo Cavallini cavall...@faunalia.it

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Il 15/01/2014 18:17, Lynkos ha scritto:
  I've been given a shape file representing a vegetation map which I now
 have to
  modify, merging a number of polygons. When I do this, in almost all
 cases the merge
  leaves a number of lines, either attached to one of the polygons or
 completely
  isolated. An example of the problem (one of the worst) is illustrated
 in the
  following screenshots.

 Hi Lynkos,
 I think this is another side of this issue:
 http://lists.osgeo.org/pipermail/qgis-developer/2014-January/030119.html
 Contributions welcome.
 All the best.

 - --
 Paolo Cavallini - www.faunalia.eu
 Corsi QGIS e PostGIS: http://www.faunalia.eu/training.html
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1
 Comment: Using GnuPG with Icedove - http://www.enigmail.net/

 iEYEARECAAYFAlLWzVIACgkQ/NedwLUzIr5FfACfQ8GfFPlfFw+gCN5Qnb5609wR
 s7sAn3iGkHiGWCZlEoLxE+5f7/5GgY4q
 =qUQR
 -END PGP SIGNATURE-
 ___
 Qgis-user mailing list
 Qgis-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-user




 --
 *Sarah Gregg*
 immagini - parole - territorio - natura
 Web: www.wild-eyes.eu

 ___
 Qgis-user mailing list
 Qgis-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-user




-- 
Tim Sutton - QGIS Project Steering Committee Member
==
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Irc: timlinux on #qgis at freenode.net
==
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user