<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>If the rasters have discrete values (which you imply) I would dump out polygons from the rasters using ST_DumpAsPolygons (<a href="http://postgis.net/docs/RT_ST_DumpAsPolygons.html">http://postgis.net/docs/RT_ST_DumpAsPolygons.html</a>) and then use pure geometry-functions to calculate intersections between your city polygons and your new coverage polygons.</div><div><br></div><div>Calculating areas etc. from the individual geometries and intersections is also going to be easy with this approach.</div><div><br></div><div>-ra</div><br><div><div>On 16 Apr 2015, at 20:24, Roberto Lazarte Kaqui <<a href="mailto:roberto.kaqui@ipea.gov.br">roberto.kaqui@ipea.gov.br</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="PT-BR" link="blue" vlink="purple" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">I have a raster with one band that represents the deforested area in the Amazon. This raster has 13 categories representing the deforested area in each year from 2001 to 2013.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">Beyond this raster data, i have a database with 800 polygons that represents 800 cities of the Amazon region.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">My interest is calculate the total deforested area in each city of the region for each year. In other words, i need to calculate the intersection area between the raster and the polygons database for each category of the raster.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">In this scenario, i have two main questions:<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">1 - What's the best way to do raster/polygon intersections? I read about two different approaches, one using ST_Intersection and the other one using ST_Clip. The second one apparently is faster and more efficient, but i don't know about its precision.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">2 - Assuming that i used ST_Clip to do the intersections, the result it’s gonna be another raster. How can i calculate the area of each category of this raster?<o:p></o:p></span></div></div>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@lists.osgeo.org" style="color: purple; text-decoration: underline;">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" style="color: purple; text-decoration: underline;">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></div></blockquote></div><br></body></html>