<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16722"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial>Have you looked at ST_Intersection. I'm not sure how
large your grids are so might still be a bit too slow.
</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff><A
href="http://www.postgis.org/documentation/manual-svn/RT_ST_Intersection.html">http://www.postgis.org/documentation/manual-svn/RT_ST_Intersection.html</A></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial>Below is a link to our slides from our North Carolina GIS
meeting that may answer some of your questions (shows some Raster
examples) as well as the 3D ones people have asked.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff><A
href="http://www.postgis.us/presentations">http://www.postgis.us/presentations</A></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=310444701-23022011><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=310444701-23022011></SPAN><FONT face=Arial><FONT
color=#0000ff><FONT size=2>Hope that helps,</FONT></FONT></FONT></DIV>
<DIV><SPAN class=310444701-23022011></SPAN><FONT face=Arial><FONT
color=#0000ff><FONT size=2>R<SPAN class=310444701-23022011>egina and
Leo</SPAN></FONT></FONT></FONT><BR></DIV>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of
</B>Andreas Forø Tollefsen<BR><B>Sent:</B> Tuesday, February 22, 2011 4:28
AM<BR><B>To:</B> PostGIS Users Discussion<BR><B>Subject:</B> [postgis-users]
ST_Value from Polygon<BR></FONT><BR></DIV>
<DIV></DIV>Hi all,
<DIV><BR></DIV>
<DIV>I am working with a large raster dataset that i want to aggregate into
vector grids.</DIV>
<DIV>The raster dataset is a landcover dataset, and i want to find which of the
raster values are the most dominant within each of the vector grid cells.</DIV>
<DIV><BR></DIV>
<DIV>I have been looking at the ST_Value function, but this is not usable
together with the cell polygon.</DIV>
<DIV><BR></DIV>
<DIV>I have written a script that gives me the raster value of the centroid of
each cell, but i want to find which raster class is the largest.</DIV>
<DIV>Hence i need to calculate the area of each raster class within each cell
and select the largest class.</DIV>
<DIV><BR></DIV>
<DIV>Any idea? So far i have only come this far:</DIV>
<DIV><BR></DIV>
<DIV>
<DIV>DROP TABLE IF EXISTS globshortpoly;</DIV>
<DIV>SELECT priogrid_land.cell, ST_Value(rast, ST_Centroid(cell))</DIV>
<DIV>INTO globshortpoly</DIV>
<DIV>FROM priogrid_land, globshort</DIV>
<DIV>WHERE rast && priogrid_land.cell </DIV>
<DIV>LIMIT 1000</DIV></DIV></BODY></HTML>