[postgis-users] Removing tiny polygons

Rémi Cura remi.cura at gmail.com
Tue Jan 28 01:45:22 PST 2014


It is possible to do by groupping :

the idea is :
you group small polygons by the coordinate of there centroid, rounded (or
snapped ot grid) so that polygon less than XX meter are in the same group.

Example :
SELECT ST_Union(poly.geom )
FROM my_poly AS poly
GROUP BY ST_SnapToGrid(ST_Centroid(poly.geom),XX)

Please note that this code doesn't enforce the fact that polygons are
touching to merge, but you don"t really need this, because separate
polygons will get merged into a multipolygons, which is easy to deal with
by dump .

Cheers,

Rémi-C



2014-01-28 Morten Sickel <morten at sickel.net>

> I never used it, but it should be along the lines discussed here:
> http://gis.stackexchange.com/questions/49650/merge-polygons-in-postgis
>
> if it is just a few, it should be doable to do manually - I don't know if
> it is possible to do automatically in SQL
>
> For each poly with area < some_limit{
>    find largest neighboring poly
>     // or smallest, or whatever were you are sure you'll get a
> well-defined answer
>    join the two polys
> }
>
> Morten
>
>
> Astrid Bjørnerød skrev:
> > Is there anyone you have written some sql-code for removing the small
> > polygons onto one of the neighbor-polygons ?
> > Any stabil functions for this task?
> >
> > Astrid
> >
> > -----Opprinnelig melding-----
> > Fra: postgis-users-bounces at lists.osgeo.org
> > [mailto:postgis-users-bounces at lists.osgeo.org] På vegne av Tom McCallum
> > Sendt: 27. januar 2014 20:48
> > Til: morten at sickel.net; PostGIS Users Discussion
> > Emne: Re: [postgis-users] Removing tiny polygons
> >
> > Thanks Morten.  I wanted the first case, so that helps.
> >
> > On Mon, 27 Jan 2014 19:15:18 -0000, Morten Sickel <morten at sickel.net>
> > wrote:
> >
> >> It depends on what you mean with "remove" - do you want to just have
> >> the large polygons without the area that is covered by the small ones
> >> or do you want to add the area of the small polygons onto one or more
> >> of the larges? (e.g. how one typically wants to handle shiver
> >> polygons)
> >>
> >> In the first case it is as easy as a query like
> >>
> >> select the_geom where ST_area(the_geom) > ...
> >>
> >> Morten
> >>
> >>
> >> Tom McCallum skrev:
> >>> Hi all,
> >>>
> >>> If I have a polygon geometry field which seems to be made up of a
> >>> large number of tiny polygons and some larger ones, what is the best
> >>> way to remove polygons below a certain size?  Would I need to
> >>> preprocess this and save in a new table/record or can I dynamically
> >>> do it?
> >>>
> >>> Thanks
> >>>
> >>> Tom
> >>> _______________________________________________
> >>> postgis-users mailing list
> >>> postgis-users at lists.osgeo.org
> >>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
> >>>
> >>
> >>
> >> _______________________________________________
> >> postgis-users mailing list
> >> postgis-users at lists.osgeo.org
> >> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at lists.osgeo.org
> > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at lists.osgeo.org
> > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
> >
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140128/6431b6fe/attachment.html>


More information about the postgis-users mailing list