<div dir="ltr">Hi PostGIS Folks,<br><br>I have a table with several polygons, some overlapping, each arbitrarily sized, and some falling across the border of France and Spain. For the sake of my question, it doesn't really matter the dimensions, number, or complexity of the polygons, but to keep things simple let's say that I have 50 of these polygons in table A.<br>
<br>I also have polygons representing France and Spain, stored in table B with country_name as the ... country name.<br><br>The goal of this exercise is to compute the sum of all unique coverage by polygons over each country. So the first thing I need to do is dissolve the polygons where they intersect to get rid of overlap. Let's say I do this using ST_MemUnion and use the political borders in table B as follows:<br>
<br>CREATE TABLE dissolved_polygons AS SELECT ST_MemUnion(a.the_geom), b.country_name FROM a LEFT JOIN b ON ST_Intersects(a.the_geom, b.the_geom)<br><br>Now table dissolved_polygons has 2 entries - one for france and one for spain. Each is a multi-polygon representing the coverage in each country. However, for dissolved polygons that span the border, they are fully represented in each country. My question at this point is how I can then delete any portion of the polygon in France that extends into Spain, and vice-verca? <br>
<br>Perhaps there is a better way altogether to do this? Maybe use ST_Difference on the original non-dissolved polygons?<br><br>I hope my question is clear enough.<br><br>Many Thanks.<br>-dylan<br>
</div>