[postgis-users] Create a view and dissolve on attribute

Michael Fuhr mike at fuhr.org
Thu Aug 10 22:56:01 PDT 2006


On Fri, Aug 11, 2006 at 03:15:23PM +1000, Craig Feuerherdt wrote:
> I can create a view of categories by doing something like "select poly.oid,
> category.cat from poly, category where poly.polyid = category.polyid;"
> 
> Is it possible to dissolve the polygon geometries based on the category in
> the select statement above?

Is the following what you're looking for?  If not then please explain
in more detail what you'd like to do.

CREATE VIEW catview AS
SELECT c.cat, GeomUnion(p.geom) AS geom
FROM poly AS p
JOIN category AS c ON c.polyid = p.polyid
GROUP BY c.cat;

-- 
Michael Fuhr



More information about the postgis-users mailing list