Wednesday, March 25, 2009

Problem with PostGIS ST_Buffer

Seems like I'm not getting back all of the geometry from a query.

select name, Buffer(the_geom, .12) from coastlines where iso_3_code = 'PNG';



After a bit of screwing around, the solution I found is to blow up the MULTIPOLYGON that is Papua New Guinea with ST_Dump, then ST_Buffer each of the individual polygons, and finally return those buffered polygons as a subquery result to the geomunion function. Like this:

SELECT c.name, geomunion(the_geom) FROM (SELECT name, ST_Buffer((ST_Dump(the_geom)).geom, .12) AS the_geom FROM coastlines) c WHERE c.name LIKE 'Papua%' GROUP BY c.name;

The results look like this:


Works, but it doesn't seem like this should be necessary.

No comments: