[postgis-users] 2 Questions

Dylan Lorimer edylan at google.com
Fri Apr 18 14:46:36 PDT 2008


Sorry for the barrage of questions lately! But suddenly PostGIS is
becoming extremely useful to my day-to-day activities. So congrats on
a fantastic product that is letting me (thus far) skip on purchasing
any ESRI software.

Questions:

1) Given N polygons in a table called A, and another table of country
borders, how do I generate a set of polygons that represent where the
N polygons of table A do NOT exist? Sort of a mask of the polygons in
A clipped by a country border. Actually, I know how to clip by
borders, so I'm really just looking for how to find the area not
occupied by polygons in A.

2) I know this one has been beaten to death on this list, but yet in
the archives I still can't exactly find what I want. I've got absurd
amounts of polygons, millions. But for the sake of argument let's just
say I have a lot. I've also got country borders. I can easily find
which polys fall within certain countries, but what I want to do is
then generalize those polys that overlap into single polygons. It
appears as if ST_Union is my candidate, but I can't see to get it
working. Do I need to join against the same table?

Here's what I've so far come up with but that I don't think is correct:

select ST_Union(a.the_geom,b.the_geom) as the_geom from the_table a,
the_table b where ST_Intersects(a.the_geom, b.the_geom);

Any thoughts on this would be helpful.

Cheers!
-dylan



More information about the postgis-users mailing list