In OpenStreetMap there are sometimes multipolygons where attributes are present on both the polygon and the multipolygon relation, such as the Grampians National Park:


These polygons get loaded by OSM2pgsql separately, so I get duplicate polygons in PostGIS. Both match a query like select * from planet_osm_polygon where leisure='nature_reserve'.

The problem is that when rendering such polygons using a transparent style (eg, over a terrain basemap) they appear darker than other single polygons.

enter image description here

I can't think of any way to avoid this happening, short of not rendering any multipolygons, or only multipolygons.

Any suggestions? Pre-processing in PostGIS is ok if needed.

  • You could separately select polygons and multipolygons using st_geometrytype and then see which of these overlap in PostGIS. – raphael Aug 18 '15 at 19:33

JOIN on the common characteristics such that the redundant entries match each other, and then delete the one with the smaller area in every case. In that way, you'll only render the larger multipolygon of which the smaller is only a part.

INNER JOIN table2 -- same table joined to itself
  ON name1 = name2 AND (boundary1 = boundary2 OR ... (insert other transparent rendering things here) )
WHERE ST_area(geometry1) < ST_area(geometry2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.