Hi Daniel.<br><br>You should use v.rast.stats [1] as it "Calculates univariate statistics from a raster map based on <br>vector polygons and uploads statistics to new attribute columns.
" Should be a more straight<br>forward approach.<br><br>Best Regards,<br>Daniel. <br><br>[1] <a href="http://grass.osgeo.org/gdp/html_grass64/v.rast.stats.html">http://grass.osgeo.org/gdp/html_grass64/v.rast.stats.html</a><br>
<br><br><div class="gmail_quote">On Mon, Nov 21, 2011 at 3:40 PM, Daniel Lee <span dir="ltr"><<a href="mailto:lee@isi-solutions.org">lee@isi-solutions.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi group,<div><br></div><div>Does anyone have a good idea of how to join vector areas by location? I'm trying to do aggregated statistics on vector maps using extracted values from rasters. I want the sum of the raster cells that lie within the vectors to be inserted into the vector attribute table. So far I've done stuff along these lines, but it's got a problem, and the main problem is that when I convert the rasters to polygons the polygons end up with stair-like boundaries rather than the smooth boundaries they had before they were converted to rasters. A second problem if I overlay the stair-like polygons over the original areas, the product of v.overlay is two polygons with a single centroid, which is absolutely wrong.</div>
<div><br></div><div>Here's what I've been doing:</div><div>1. Convert the polygons to rasters with v.to.rast</div><div>2. Convert the rasters that I want to sum into the polygons to integers with r.mapcalc</div><div>
3. Find the sums of the rasters for each polygon (in raster form) with r.statistics</div><div>4. Extract the summed values from the product of r.statistics with r.mapcalc, so that each polygon has the sum from the rasters as its value for all pixels.</div>
<div>5. Convert the rasters to vectors with r.to.vect</div><div>-- This is where the first problem comes up - the boundaries are very jagged.</div><div>6. Connect the attributes with v.overlay</div><div>-- Second problem: I get all the boundaries, not just the smooth ones or the jagged ones.</div>
<div><br></div><div>Ideas:</div><div>- Extract the centroids from the polygons and then join the polygon tables (extract the centroids with v.select, then use v.overlay? And as a last step use v.db.join to join the new values to the old geometries and get rid of the jagged boundaries?</div>
<div>- Convert the rasters to points and then sum them inside the polygons? With what tool?</div><div><br></div><div>Problems:</div><div>- How can I connect the tables that no longer have thematic connections by the position of the geometries they belong to? I can connect the tables to the geometries by adding a layer to the map, but then I can't e.g. add the values of different fields together. I'm kind of at a loss.</div>
<div><br></div><div>Thanks a lot fo the help!</div><div>Daniel</div><div>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"></span></p><p>--<br></p><p>B.Sc. Daniel Lee<br>
Geschäftsführung für Forschung und Entwicklung<br>ISIS - International Solar Information Solutions</p><p>Deutschhausstr. 10<br>35037 Marburg<br>Festnetz: <a value="+4964213796256" style="color:rgb(28,81,168)">+49 6421 379 6256</a><br>
Mobil: <a value="+4917661277269" style="color:rgb(28,81,168)">+49 176 6127 7269</a><br>E-Mail: <a href="mailto:Lee@isi-solutions.org" style="color:rgb(28,81,168)" target="_blank">Lee@isi-solutions.org</a><br>Web: <a href="http://www.isi-solutions.org/" style="color:rgb(28,81,168)" target="_blank">http://www.isi-solutions.org</a></p>
<p>ISIS wird gefördert durch die Bundesrepublik Deutschland, Zuwendungsgeber: Bundesministerium für Wirtschaft und Technologie aufgrund eines Beschlusses des Deutschen Bundestages, sowie durch die Europäische Union, Zuwendungsgeber: Europäischer Sozialfonds.<br>
Zusätzliche Unterstützung erhält ISIS von dem Entrepreneurship Cluster Mittelhessen, der Universität Marburg, dem Laboratory for Climatology and Remote Sensing und dem GIS-Lab Marburg.</p><p></p><br>
</div>
<br>_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br></blockquote></div><br>