[GRASS-user] Joining vectors by location
Daniel Lee
lee at isi-solutions.org
Mon Nov 21 09:40:36 EST 2011
Hi group,
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.
Here's what I've been doing:
1. Convert the polygons to rasters with v.to.rast
2. Convert the rasters that I want to sum into the polygons to integers
with r.mapcalc
3. Find the sums of the rasters for each polygon (in raster form) with
r.statistics
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.
5. Convert the rasters to vectors with r.to.vect
-- This is where the first problem comes up - the boundaries are very
jagged.
6. Connect the attributes with v.overlay
-- Second problem: I get all the boundaries, not just the smooth ones or
the jagged ones.
Ideas:
- 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?
- Convert the rasters to points and then sum them inside the polygons? With
what tool?
Problems:
- 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.
Thanks a lot fo the help!
Daniel
--
B.Sc. Daniel Lee
Geschäftsführung für Forschung und Entwicklung
ISIS - International Solar Information Solutions
Deutschhausstr. 10
35037 Marburg
Festnetz: +49 6421 379 6256
Mobil: +49 176 6127 7269
E-Mail: Lee at isi-solutions.org
Web: http://www.isi-solutions.org
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.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20111121/ab9e56c6/attachment.html
More information about the grass-user
mailing list