Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

One table has a series of grid squares in it, and the other has millions of voronoi polygons in it. I need to create a table that has the difference between the two of the them so that I effectively get the holes in the voronoi layer.

I've tried several things like this:

SELECT st_astext(ST_Difference(density_squares.geom, 
       st_collect(density_squares_voronoi.geom))) As new_geom    
FROM density_squares_voronoi left JOIN density_squares ON
       ST_Intersects(density_squares.geom,density_squares_voronoi.geom)
group by 
       density_squares.geom;

But I get one output gridsquare for every voronoi polygon instead of the one cropped polygon like I need. Will I need to union the voronoi layer first or something?


I had to crack on and get it finished, so I just wrote some .net code to run it as a batch process. However I'm now trying to union the data and that is also taking a long time. A screen shot is here of what it looks like

enter image description here

and the sql i'm trying to use is this:

Select st_union(density_square_islands.islands) 
into density_square_islands_union 
from density_square_islands 
where st_touches(density_square_islands.islands,density_square_islands.islands)

You can see the individual squares within the cropped islands. I just need to union the squares within each island into a single polygons

share|improve this question

closed as not a real question by underdark Nov 6 '12 at 18:23

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
ST_Intersect first - postgis.refractions.net/docs/ST_Intersects.html do you have a screen shot of your current output –  Mapperz Oct 30 '12 at 13:30
    
could you give me an example or pseudocode about how to use intersect first? Only I did try something like this but the output was still seperate versions of the main polygon each with a single voronoi cut out. its like I want to crop single geometry against whole table, but the functions want to crop each geometry against each geometry, hence the duplication. –  Rob_Smart Oct 30 '12 at 14:04
    
You haven't explained your problem clearly enough to solve it. As Mapperz notes, a simple picture of your inputs and desired output would go a long way towards that. –  Paul Ramsey Oct 30 '12 at 20:09
    
Hi, Sorry for not uploading picture. I couldn't figure out how to do it. Its ok I had to crack on and get it finished, so I just wrote some .net code to run it as a batch process. However I'm now trying to union the data and that is also taking a long time. A screen shot is here of what it looks like [IMG]i46.tinypic.com/2ut6kqc.png[/IMG] and the sql i'm trying to use is this: Select st_union(density_square_islands.islands) into density_square_islands_union from density_square_islands where st_touches(density_square_islands.islands,density_square_islands.islands); thanks –  Rob_Smart Oct 31 '12 at 10:34
    
that url might not work: try this tinypic.com/r/2ut6kqc/6 You can see the individual sqaures within the cropped islands. I just need to union the squares within each island into a single polygons –  Rob_Smart Oct 31 '12 at 10:48
add comment

Browse other questions tagged or ask your own question.