Re: [postgis-users] How to eliminate small gaps produced by ST_union?
It will be _very_ slow. So much that you may prefer to make the topology persistent. Another approach I'd like to see implemented would be to expose a tolerance to the GEOS implemented functions. Basically exposing the GEOS PrecisionModel. By doing that you could specify a tolerance in the overlay operations and the result should never have gaps bigger than the given tolerance. --strk; On Thu, Oct 25, 2012 at 10:28:19AM -0700, pcr...@pcreso.com wrote: My impression is that working topologies is slow, especially with large datasets - lots of computation involved. How effective would this be with hundreds of thousands or millions or small polygons? Just running ST_Union() takes hours to days. Thanks Brent Wood --- On Fri, 10/26/12, Sandro Santilli s...@keybit.net wrote: From: Sandro Santilli s...@keybit.net Subject: Re: [postgis-users] How to eliminate small gaps produced by ST_union? To: PostGIS Users Discussion postgis-users@postgis.refractions.net Date: Friday, October 26, 2012, 6:04 AM You may try to construct a topology within PostGIS-2.0, using a small tolerance, and then get the geometries back. --strk; On Thu, Oct 25, 2012 at 05:54:05PM +0100, Alexandre Neto wrote: I'm trying to Aggregate\Dissolve a set of adjacent, but not touching polygons in Postgis. The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I used ST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. [image: Inline image 2] Is there a way to eliminate this gaps or small angles within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users -- http://www.cartodb.com - Map, analyze and build applications with your data ~~ http://strk.keybit.net ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
Have you considered curve smoothing or apply a small buffer around the orginal data/ Sandro Santilli wrote: It will be _very_ slow. So much that you may prefer to make the topology persistent. Another approach I'd like to see implemented would be to expose a tolerance to the GEOS implemented functions. Basically exposing the GEOS PrecisionModel. By doing that you could specify a tolerance in the overlay operations and the result should never have gaps bigger than the given tolerance. --strk; On Thu, Oct 25, 2012 at 10:28:19AM -0700, pcr...@pcreso.com wrote: My impression is that working topologies is slow, especially with large datasets - lots of computation involved. How effective would this be with hundreds of thousands or millions or small polygons? Just running ST_Union() takes hours to days. Thanks Brent Wood --- On Fri, 10/26/12, Sandro Santilli s...@keybit.net wrote: From: Sandro Santilli s...@keybit.net Subject: Re: [postgis-users] How to eliminate small gaps produced by ST_union? To: PostGIS Users Discussion postgis-users@postgis.refractions.net Date: Friday, October 26, 2012, 6:04 AM You may try to construct a topology within PostGIS-2.0, using a small tolerance, and then get the geometries back. --strk; On Thu, Oct 25, 2012 at 05:54:05PM +0100, Alexandre Neto wrote: I'm trying to Aggregate\Dissolve a set of adjacent, but not touching polygons in Postgis. The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I used ST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. [image: Inline image 2] Is there a way to eliminate this gaps or small angles within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users -- http://www.cartodb.com - Map, analyze and build applications with your data ~~ http://strk.keybit.net ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users -- ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
Thank you for all the answers. I did not try the topology, as I need to study its implementation a little better. I did not found the st_cleanpolygon function and using (St_Buffer, 0) did not worked: The dilate\erode visually corrects the problem, but of course introduce a small rounding in the angle introducing a small overlaping with other adjacent polygons... I guess that the tolerance with the GEOS PrecisionModel would be nice, I think that is the method used by ArcGIS products to insure geometry topology after aggregation operations. Any more ideas? Alexandre Neto On Fri, Oct 26, 2012 at 8:40 AM, Dave Potts dave.po...@pinan.co.uk wrote: Have you considered curve smoothing or apply a small buffer around the orginal data/ Sandro Santilli wrote: It will be _very_ slow. So much that you may prefer to make the topology persistent. Another approach I'd like to see implemented would be to expose a tolerance to the GEOS implemented functions. Basically exposing the GEOS PrecisionModel. By doing that you could specify a tolerance in the overlay operations and the result should never have gaps bigger than the given tolerance. --strk; On Thu, Oct 25, 2012 at 10:28:19AM -0700, pcr...@pcreso.com wrote: My impression is that working topologies is slow, especially with large datasets - lots of computation involved. How effective would this be with hundreds of thousands or millions or small polygons? Just running ST_Union() takes hours to days. Thanks Brent Wood --- On Fri, 10/26/12, Sandro Santilli s...@keybit.net wrote: From: Sandro Santilli s...@keybit.net Subject: Re: [postgis-users] How to eliminate small gaps produced by ST_union? To: PostGIS Users Discussion postgis-users@postgis.refractions.net Date: Friday, October 26, 2012, 6:04 AM You may try to construct a topology within PostGIS-2.0, using a small tolerance, and then get the geometries back. --strk; On Thu, Oct 25, 2012 at 05:54:05PM +0100, Alexandre Neto wrote: I'm trying to Aggregate\Dissolve a set of adjacent, but not touching polygons in Postgis. The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I used ST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. [image: Inline image 2] Is there a way to eliminate this gaps or small angles within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users -- http://www.cartodb.com - Map, analyze and build applications with your data ~~ http://strk.keybit.net ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users -- ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
On Fri, Oct 26, 2012 at 10:05:29AM +0100, Alexandre Neto wrote: Thank you for all the answers. I did not try the topology, as I need to study its implementation a little better. I did not found the st_cleanpolygon function and using (St_Buffer, 0) did not worked: The dilate\erode visually corrects the problem, but of course introduce a small rounding in the angle introducing a small overlaping with other adjacent polygons... I guess that the tolerance with the GEOS PrecisionModel would be nice, I think that is the method used by ArcGIS products to insure geometry topology after aggregation operations. Any more ideas? You may try collecting all vertices of input into a MULTIPOINT, then ST_SnapToGrid that MULTIPOINT, then ST_Snap each of the input geometries to the resulting MULTIPOINT, with your desired tolerance. Finally pass the result trough ST_MakeValid to drop collapsed polygons. Should work fine. Let us know. --strk; http://www.cartodb.com - Map, analyze and build applications with your data ~~ http://strk.keybit.net ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
That seamed to have worked. Here is my implementation of Sandro guidelines: SELECT ST_Union(v.the_geom) FROM (SELECT ST_MakeValid(St_Snap(t.the_geom, (SELECT ST_SnapToGrid(st_collect(f.the_geom), 0.001) as the_geom FROM (SELECT (ST_DumpPoints(g.the_geom)).geom as the_geom FROM table1 as g) as f), 0.001)) as the_geom FROM table1 as t) as v; It's obviously a slow process as it implies 2 sequential reads in the table, it takes 11ms with a very simple table containing only 2 polygons, as it implies 2 sequential reads in the table. With a bigger table ( 701 polygons, 113147 vertices), it takes 762575 ms... Since the problem occurs when I do the input of new polygons, I will try to use this procedures only for the new polygons and the adjacent ones. Thank you for your help. Alexandre Neto On Fri, Oct 26, 2012 at 10:20 AM, Sandro Santilli s...@keybit.net wrote: On Fri, Oct 26, 2012 at 10:05:29AM +0100, Alexandre Neto wrote: Thank you for all the answers. I did not try the topology, as I need to study its implementation a little better. I did not found the st_cleanpolygon function and using (St_Buffer, 0) did not worked: The dilate\erode visually corrects the problem, but of course introduce a small rounding in the angle introducing a small overlaping with other adjacent polygons... I guess that the tolerance with the GEOS PrecisionModel would be nice, I think that is the method used by ArcGIS products to insure geometry topology after aggregation operations. Any more ideas? You may try collecting all vertices of input into a MULTIPOINT, then ST_SnapToGrid that MULTIPOINT, then ST_Snap each of the input geometries to the resulting MULTIPOINT, with your desired tolerance. Finally pass the result trough ST_MakeValid to drop collapsed polygons. Should work fine. Let us know. --strk; http://www.cartodb.com - Map, analyze and build applications with your data ~~ http://strk.keybit.net ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
You may try to construct a topology within PostGIS-2.0, using a small tolerance, and then get the geometries back. --strk; On Thu, Oct 25, 2012 at 05:54:05PM +0100, Alexandre Neto wrote: I'm trying to Aggregate\Dissolve a set of adjacent, but not touching polygons in Postgis. The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I used ST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. [image: Inline image 2] Is there a way to eliminate this gaps or small angles within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
My impression is that working topologies is slow, especially with large datasets - lots of computation involved. How effective would this be with hundreds of thousands or millions or small polygons? Just running ST_Union() takes hours to days. Thanks Brent Wood --- On Fri, 10/26/12, Sandro Santilli s...@keybit.net wrote: From: Sandro Santilli s...@keybit.net Subject: Re: [postgis-users] How to eliminate small gaps produced by ST_union? To: PostGIS Users Discussion postgis-users@postgis.refractions.net Date: Friday, October 26, 2012, 6:04 AM You may try to construct a topology within PostGIS-2.0, using a small tolerance, and then get the geometries back. --strk; On Thu, Oct 25, 2012 at 05:54:05PM +0100, Alexandre Neto wrote: I'm trying to Aggregate\Dissolve a set of adjacent, but not touching polygons in Postgis. The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I used ST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. [image: Inline image 2] Is there a way to eliminate this gaps or small angles within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
Try to use function st_cleanpolygon or st_buffer with a radius of 0.0. Regards Bo Victor Thomsen Aestas-GIS Denmark Den 25-10-2012 18:54, Alexandre Neto skrev: I'm trying toAggregate\Dissolve a set of adjacent, but not touching polygons in Postgis.The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I usedST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. Is there a way to eliminate this "gaps" or "small angles" within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] How to eliminate small gaps produced by ST_union?
If you don't mind altering your other edges somewhat in the process, dilate/erode will blow those away, http://blog.opengeo.org/2010/11/22/removing-complexities/ P. On Thu, Oct 25, 2012 at 10:44 AM, Bo Victor Thomsen bo.victor.thom...@gmail.com wrote: Try to use function st_cleanpolygon or st_buffer with a radius of 0.0. Regards Bo Victor Thomsen Aestas-GIS Denmark Den 25-10-2012 18:54, Alexandre Neto skrev: I'm trying to Aggregate\Dissolve a set of adjacent, but not touching polygons in Postgis. The geometries were created editing the Postgis table in QGIS created, with snapping and avoid overlap in the layer. I used ST_Union like this: SELECT ST_Union(the_geom) FROM table; Small gaps similar to lines appear in the result. This happens when the adjacent polygons do not share the exact same vertices. Is there a way to eliminate this gaps or small angles within Postgis? I know that v.clean in GRASS can eliminate small angles, and correct topology, but that would mean I needed to copy the features to GRASS, correct them and copy it back to Postgis. Thanks in advance, Alexandre Neto ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users