[postgis-users] Difference polygon sets

Nicklas Avén nicklas.aven at jordogskog.no
Fri Aug 27 08:12:36 PDT 2010


Hallo Espen

ST_Difference cuts in the polygons to give the difference. 
It looks like your dissolved polygons contains one or more original
polygons, not just parts of them.

Then it is enough to find what original polygons is used in the
dissolve.

You can find those polygons with a query like this:

SELECT a.* 
FROM original_data a LEFT JOIN dissolved_data b 
	ON ST_WITHIN(a.the_geom, b.the_geom) 
WHERE b.gid is null;

I see you have no id or primary key in your dissolved dataset, so you
can use any field in the where-part as long as you know it never has
null as value.
I would add an id field just to be sure.

Är det data från lasertakst eller..?
Bara nyfiken :-)

HTH
/Nicklas



 On Fri, 2010-08-27 at 14:04 +0200, Espen Isaksen wrote:
> Hi!
> 
> I have a set of polygons where I have dissolved some of the polygons.
> So I get two sets of polygons where one set is my original data, and
> the other set is new polygons from the dissolve operations. Now I want
> to extract the remaining polygons from my original dataset which were
> not dissolved. I tried just a simple st_difference, but from what I
> understand this operation does now work on sets of polygons.
> 
> Both datasets can be found here in shape format:
> http://dl.dropbox.com/u/8829/postgis.zip
> 
> How can I extract only the remaining polygons from the original
> dataset. I had a look at this
> post(http://www.postgis.org/pipermail/postgis-users/2008-May/019511.html)
> in the mailing list, but I did not succeed in changing it to fit my
> purpose.
> 
> Can anybody help me out?
> 
> Kind regards,
> Espen Isaksen
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 





More information about the postgis-users mailing list