[GRASS-user] Rasterize polygons, multiple polygons per grid cell

Hi

I have been desperately trying to figure out how to solve the task described
below in GRASS (via R using spgrass6). I have searched the list, but did not
find exactly what I was looking for.

I have a large polygon file, app. 250000 polygons. It is the GLWD-2 data set
available here
<http://worldwildlife.org/publications/global-lakes-and-wetlands-database-small-lake-polygons-level-2&gt;
The map is in lat long. My goal is to end up with a raster layer in Behrmann
projection with app 96486.28m by 96486.28m grid cells showing the area per
grid cell covered by polygons in the GLWD-2 layer.

So as I see it the task is to, for each grid cell, "clip" the underlying
polygon file, calculate the area and return that value in the resulting
raster.

So far I have successfully imported the shape file and reprojected it to a
location with the desired projection and resolution. So far so good.

Then I imported a raster with the desired grid cell size and dimensions. So
now I seem to have the layers I need in the same location.

Then I some how want to do the actual clipping and calculation of the area
of polygons in each cell. This is where I get stuck. Any suggestions to a
newbie?

Initially I thought I somehow could specify which function(e.g. sum, mean
etc) should be used in v.to.rast in the case of multiple polygons falling in
the same grid cell. But I could not find anything here.

I'm running GRASS 7.0 on OSX btw.

Any help and suggestions would be highly appreciated!

Best regards,
Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Lars,

did you try...

... to convert your polygon to a raster.

And make sure before you set the resolution:

Hope that helps

Stefan

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005286.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Stefan

Thank your for your suggestion!

Yes, I did try v.to.rast exactly as you suggested. I use the attribute
AREA_SKM in the GLWD file. It is describing the area of the polygon in
square kilometres.

But the resulting file only contains 116 non NA cells. This is clearly too
few.

There is a couple of things I am not quite sure of how the v.to.rast
handles.
What determines if a cell gets a value? Does the cell centroid have to be
covered by the polygon file? If this is the case then that might explain why
I get so few non NA cells.
And how is v.to.rast dealing with the situation where more than on polygon
falls within a cell? Does it take the mean, max or sum or something else?
What happens in the case where a polygon extends from one cell into another?

Ones again thanks for your help!

Best
Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005326.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 09/28/2012 09:49 PM, Lars Dalby wrote:

Hi

I have been desperately trying to figure out how to solve the task described
below in GRASS (via R using spgrass6). I have searched the list, but did not
find exactly what I was looking for.

I have a large polygon file, app. 250000 polygons. It is the GLWD-2 data set
available here
<http://worldwildlife.org/publications/global-lakes-and-wetlands-database-small-lake-polygons-level-2&gt;
The map is in lat long. My goal is to end up with a raster layer in Behrmann
projection with app 96486.28m by 96486.28m grid cells showing the area per
grid cell covered by polygons in the GLWD-2 layer.

If I understand your task, you want to
* import the GLWD lakes polygon shapefile into GRASS
* reproject to a projected CRS
* create a GRID with cell size about 92 km. X 92 km, and
* sum up the area of lakes within each grid cell.
Here's a GRASS-only procedure to do that:

First I downloaded the polygon shapefile you linked to. THen I started GRASS in a WGS84 based LOCATION, and used:
# Use the '-o' option since the downloaded shapefile does not have a *.prj
v.in.ogr -o dsn=glwd_2.shp out=glwd

Next I restarted GRASS and created a new location based on the EPSG code 3925. This is NOT World Behrmann, but it's a cylindrical equal area projection with meters as units, like Behrmann. I couldn't find any proj4 reference to Behrmann :frowning:

At this step, I made sure to set the default database connection to sqlite. (This is important later to aggregate the water body areas in each grid cell.):
eval `g.gisenv`
db.connect driver=sqlite database=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db

Now:
v.proj in=glwd loc=<the WGS84 LOCATION> map=<the previous MAPSET>

Next step, I created a grid using v.mkgrid. I limited the region to just Africa so things would move along a little faster. So something like:
# Create a vector grid with size 92,000 meters by 92,000 meters
v.mkgrid --o grid92 position=coor coor=-2000000,-5000000 box=92000,92000 grid=140,85
# I got the 'grid=' parameters by dividing the length and width by 92,000

Now I use v.overlay to find the intersection of these two vectors. This takes a while since all the lakes need to be clipped at the boundaries of the grid cells.
v.overlay ain=grid92 bin=glwd out=glwd_grid operator=and

After this finishes, I add a new column for the areas of each water body (now clipped to each grid cell):

v.db.addcol glwd_grid col="clip_area double precision"
# calculate the area of each clipped water surface
v.to.db glwd_grid opt=area col=clip_area

The new glwd_grid vector now has in its attrib table:
v.info -c glwd_grid
  Displaying column types/names for database connection of layer 1:
INTEGER|cat
INTEGER|a_cat
INTEGER|a_row
INTEGER|a_col
INTEGER|b_cat
INTEGER|b_GLWD_ID
CHARACTER|b_TYPE
CHARACTER|b_POLY_SRC
DOUBLE PRECISION|b_AREA_SKM
DOUBLE PRECISION|b_PERIM_KM
DOUBLE PRECISION|b_LONG_DEG
DOUBLE PRECISION|b_LAT_DEG
DOUBLE PRECISION|clip_area

What we need to do is SUM all clip_area values for each a_cat (grid cell category). I did this right in sqlite as follows:
sqlite3 ~/geodata/grass/Behrmann/PERMANENT/sqlite.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> SELECT a_row AS Grid_Row, a_col AS Grid_Col, SUM(clip_area) AS Sum_Areas FROM glwd_grid GROUP BY a_cat ORDER BY a_row, a_col;
Grid_Row Grid_Col Sum_Areas
---------- ---------- ---------------
9 43 11734990.811648
10 42 7600679.947002
10 43 20154750.823557
10 44 10095944.174832
10 46 18364623.744757
10 49 3054521.141835
11 41 250083.456892
11 42 9839134.964962
11 43 23519926.337785
11 44 11323614.28017
11 45 8426141.099425
11 46 12079532.459832
11 47 11135300.910967
11 49 571804.968053
11 50 1319664.199523
12 41 18036461.225015
12 42 15664405.025981
12 43 2471761.404269
12 45 2339714.549891
12 47 2890312.572311
12 48 5728571.755616
12 49 7189360.100137
12 50 3492556.03765
12 51 7318834.4634

Here's the same query using db.select:
echo 'SELECT a_row AS GridRow, a_col AS GridCol, SUM(clip_area) As "Water Area in Grid" FROM glwd_grid GROUP BY a_cat ORDER BY a_row, a_col LIMIT 20;' | db.select
GridRow|GridCol|Water Area in Grid
9|43|11734990.811648
10|42|7600679.947002
10|43|20154750.823557
10|44|10095944.174832
10|46|18364623.744757
10|49|3054521.141835
11|41|250083.456892
11|42|9839134.964962
11|43|23519926.337785
11|44|11323614.28017
11|45|8426141.099425
11|46|12079532.459832
11|47|11135300.910967
11|49|571804.968053
11|50|1319664.199523
12|41|18036461.225015
12|42|15664405.025981
12|43|2471761.404269
12|45|2339714.549891
12|47|2890312.572311

HTH,
Micha

So as I see it the task is to, for each grid cell, "clip" the underlying
polygon file, calculate the area and return that value in the resulting
raster.

So far I have successfully imported the shape file and reprojected it to a
location with the desired projection and resolution. So far so good.

Then I imported a raster with the desired grid cell size and dimensions. So
now I seem to have the layers I need in the same location.

Then I some how want to do the actual clipping and calculation of the area
of polygons in each cell. This is where I get stuck. Any suggestions to a
newbie?

Initially I thought I somehow could specify which function(e.g. sum, mean
etc) should be used in v.to.rast in the case of multiple polygons falling in
the same grid cell. But I could not find anything here.

I'm running GRASS 7.0 on OSX btw.

Any help and suggestions would be highly appreciated!

Best regards,
Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

This mail was received via Mail-SeCure System.

--
Micha Silver
GIS Consultant, Arava Development Co.
http://www.surfaces.co.il

Hi Micha

Thanks a lot for your detailed response! Much appreciated.

Micha Silver wrote

If I understand your task, you want to
* import the GLWD lakes polygon shapefile into GRASS
* reproject to a projected CRS
* create a GRID with cell size about 92 km. X 92 km, and
* sum up the area of lakes within each grid cell.

Correct, that's exactly what I am trying to do!

Micha Silver wrote

First I downloaded the polygon shapefile you linked to. THen I started
GRASS in a WGS84 based LOCATION, and used:
# Use the '-o' option since the downloaded shapefile does not have a *.prj
v.in.ogr -o dsn=glwd_2.shp out=glwd

Yep, that also what I did.

Micha Silver wrote

Next I restarted GRASS and created a new location based on the EPSG code
3925. This is NOT World Behrmann, but it's a cylindrical equal area
projection with meters as units, like Behrmann. I couldn't find any
proj4 reference to Behrmann :frowning:

I know, it is actually a bit surprising because it is quite commonly used,
at least in large-scale ecology which is my field of study. I have defined
the location myself so not a big problem. Anyhow, the steps needed in this
example does not really depend on a specific projection, so it should work
just fine no matter what projection is being used.

Micha Silver wrote

At this step, I made sure to set the default database connection to
sqlite. (This is important later to aggregate the water body areas in
each grid cell.):
eval `g.gisenv`
db.connect driver=sqlite
database=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db

I was able to excecute the db.connect command and I guess that I don't have
to use eval `g.gisenv` when I am running the commands via R?

Micha Silver wrote

Now:
v.proj in=glwd loc=
<the WGS84 LOCATION>
map=
<the previous MAPSET>

I did this step earlier also, but redid it here because the database
connection was changed.

Micha Silver wrote

Next step, I created a grid using v.mkgrid. I limited the region to just
Africa so things would move along a little faster. So something like:
# Create a vector grid with size 92,000 meters by 92,000 meters
v.mkgrid --o grid92 position=coor coor=-2000000,-5000000 box=92000,92000
grid=140,85
# I got the 'grid=' parameters by dividing the length and width by 92,000

So, this is as far as I could get in this round. When I'm running this
command I get an error message: "Parameter <coor> does not have float
value". I figure that this means that my coor values are not floating
points. They look like this: coor = -6358820,-17367529. Shouldn't that be
ok?
Hmm..., not sure what to do here.

Any hints?

Best
Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005355.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Micha

Thanks a lot for your detailed response! Much appreciated.

Micha Silver wrote

If I understand your task, you want to
* import the GLWD lakes polygon shapefile into GRASS
* reproject to a projected CRS
* create a GRID with cell size about 92 km. X 92 km, and
* sum up the area of lakes within each grid cell.

Correct, that's exactly what I am trying to do!

Micha Silver wrote

First I downloaded the polygon shapefile you linked to. THen I started 
GRASS in a WGS84 based LOCATION, and used:
# Use the '-o' option since the downloaded shapefile does not have a *.prj
v.in.ogr -o dsn=glwd_2.shp out=glwd

Yep, that also what I did.

Micha Silver wrote

Next I restarted GRASS and created a new location based on the EPSG code 
3925. This is NOT World Behrmann, but it's a cylindrical equal area 
projection with meters as units, like Behrmann. I couldn't find any 
proj4 reference to Behrmann :-(

I know, it is actually a bit surprising because it is quite commonly used,
at least in large-scale ecology which is my field of study. I have defined
the location myself so not a big problem. Anyhow, the steps needed in this
example does not really depend on a specific projection, so it should work
just fine no matter what projection is being used.

Micha Silver wrote

At this step, I made sure to set the default database connection to 
sqlite. (This is important later to aggregate the water body areas in 
each grid cell.):
eval `g.gisenv`
db.connect driver=sqlite
database=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db

I was able to excecute the db.connect command and I guess that I don't have
to use eval `g.gisenv` when I am running the commands via R?

Micha Silver wrote

Now:
v.proj in=glwd loc=
<the WGS84 LOCATION>
 map=
<the previous MAPSET>

I did this step earlier also, but redid it here because the database
connection was changed.

Micha Silver wrote

Next step, I created a grid using v.mkgrid. I limited the region to just 
Africa so things would move along a little faster. So something like:
# Create a vector grid with size 92,000 meters by 92,000 meters
v.mkgrid --o grid92 position=coor coor=-2000000,-5000000 box=92000,92000 
grid=140,85
# I got the 'grid=' parameters by dividing the length and width by 92,000

So, this is as far as I could get in this round. When I'm running this
command I get an error message: "Parameter <coor> does not have float
value". I figure that this means that my coor values are not floating
points. They look like this: coor = -6358820,-17367529. Shouldn't that be
ok?

Can you copy/paste your exact command? I think there should not be any space between ‘coor’ and ‘=’.

···
-- 
Micha Silver
GIS Consultant, Arava Development Co.
[http://www.surfaces.co.il](http://www.surfaces.co.il)

Micha Silver wrote

    Can you copy/paste your exact command? I think there should not be
    any space between 'coor' and '='.

Sure, but as I run them from R, they look a bit different that when run from
command line GRASS.

execGRASS('v.mkgrid', parameters = list(map = 'VectorGrid', position =
'coor', coor = '-6358820,-17367529', grid = '142,360', box =
'96486.28169014, 96486.28055556'))

What happens here is that the list() command will make a list with 5 slots
in this case. It looks like this:

$map
[1] "VectorGrid"

$position
[1] "coor"

$coor
[1] "-6358820,-17367529"

$grid
[1] "142,360"

$box
[1] "96486.28169014, 96486.28055556"

So it will not make any difference to what is being send to GRASS if I have
blank spaces between '=' and the values. R ignores these when making the
list. I am afraid that the problem doesn't lie here.

Do you think it could be related to the GRASS version I am running? (I am
using 7.0)

-Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005361.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Lars

Micha Silver wrote

    Can you copy/paste your exact command? I think there should not be
    any space between 'coor' and '='. 

Sure, but as I run them from R, they look a bit different that when run from
command line GRASS.

execGRASS('v.mkgrid', parameters = list(map = 'VectorGrid', position =
'coor', coor = '-6358820,-17367529', grid = '142,360', box =
'96486.28169014, 96486.28055556'))

What happens here is that the list() command will make a list with 5 slots
in this case. It looks like this: 

$map
[1] "VectorGrid"

$position
[1] "coor"

$coor
[1] "-6358820,-17367529"

$grid
[1] "142,360"

$box
[1] "96486.28169014, 96486.28055556"

So it will not make any difference to what is being send to GRASS if I have
blank spaces between '=' and the values. R ignores these when making the
list. I am afraid that the problem doesn't lie here.

Do you think it could be related to the GRASS version I am running? (I am
using 7.0)

It seems that the GRASS parser doesn’t “understand” the comma separated list of values. Here’s a bug report of the problem:
http://trac.osgeo.org/grass/ticket/739

I tried the suggestion in that link, but it still doesn’t work:

pcoor<-paste(as.integer(1), as.integer(2), sep=“,”)
pbox<-paste(as.integer(2), as.integer(2), sep=“,”)
pgrid<-paste(as.integer(2), as.integer(2), sep=“,”)
pars<-list(map=“testgrid”, grid=pgrid, coor=pcoor, box=pbox)
pars
$map
[1] “testgrid”

$grid
[1] “2,2”

$coor
[1] “1,2”

$box
[1] “2,2”

But then I still get:

doGRASS(“v.mkgrid”,flags=“overwrite”, parameters=pars)
Error in doGRASS(“v.mkgrid”, flags = “overwrite”, parameters = pars) :
Parameter does not have integer value

Can I suggest you take this issue to the r-spatial list?

Regards,
Micha

Dear Colleagues!

We would like to present a first version of our new web service with
GRASS as a calculation engine. The LandEx is a search
and retrieval tool that we are developing in Space Information Lab
(http://http://sil.uc.edu/). at University of Cincinnati.

The LandEx user interface works in an internet browser environment and
is based on following JavaScript libraries: ExtJS with GeoExt and OpenLayers.
Through this interface you have access to our new GARSS module r.retreival
prepared perform quick search on very large datasets (currently 164000 x
104000 cells). To get more information about the project see papers and
documentation available on SIL webpage.

The tool is currently under development. Only US landuse/landcover 30 m
resolution datatset is available. More layers including world-wide
geomorphometry are planned to be added soon. The source code of our
GRASS modules will be published consequently as they reach enough
maturity.

It looks that people are interested in such tool like LandEx:
http://www.theatlanticcities.com/technology/2012/09/search-engine-landscapes/3390/

We will greatly appreciate for comments and suggestion for further
development.

Pawel Nezel, Jarek Jasiewicz & The SIL Team

Micha Silver wrote

    It seems that the GRASS parser doesn't "understand" the comma
    separated list of values. Here's a bug report of the problem:
    http://trac.osgeo.org/grass/ticket/739
    
    I tried the suggestion in that link, but it still doesn't work:
    &gt; pcoor&lt;-paste(as.integer(1), as.integer(2), sep=",")
    &gt; pbox&lt;-paste(as.integer(2), as.integer(2), sep=",")
    &gt; pgrid&lt;-paste(as.integer(2), as.integer(2), sep=",")
    &gt; pars&lt;-list(map="testgrid", grid=pgrid, coor=pcoor, box=pbox)
    &gt; pars
    $map
    [1] "testgrid"
    
    $grid
    [1] "2,2"
    
    $coor
    [1] "1,2"
    
    $box
    [1] "2,2"
    
    But then I still get:
    &gt; doGRASS("v.mkgrid",flags="overwrite", parameters=pars)
    Error in doGRASS("v.mkgrid", flags = "overwrite", parameters = pars)
    :
    &nbsp; Parameter &lt;grid&gt; does not have integer value

Doesn't work for me either.

Micha Silver wrote

    Can I suggest you take this issue to the r-spatial list?

Done. Link to the thread here
<http://r-sig-geo.2731867.n2.nabble.com/execGRASS-and-v-mkgrid-gives-quot-Parameter-lt-coor-gt-does-not-have-float-value-quot-td7581061.html&gt;
.

Thanks for your help!
-Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005389.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Pawel

Can I suggest that you start a new thread with this announcement?
I think you by mistake replied in an already existing thread.

Cheers,
-Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005390.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Lars Dalby wrote

Micha Silver wrote

    Can I suggest you take this issue to the r-spatial list?

Done. Link to the thread
here
<http://r-sig-geo.2731867.n2.nabble.com/execGRASS-and-v-mkgrid-gives-quot-Parameter-lt-coor-gt-does-not-have-float-value-quot-td7581061.html&gt;
.

This issue was solved on R-sig-GEO in this thread
<http://r-sig-geo.2731867.n2.nabble.com/execGRASS-and-v-mkgrid-gives-quot-Parameter-lt-coor-gt-does-not-have-float-value-quot-td7581076.html&gt;
.
Basically the trick is to use: coor = c(-6358820,-17367529), grid =
c(142L,360L), box = c(96486.28169014, 96486.28055556)
to make sure that the values are of the right type.

-Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005648.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Micha Silver wrote

Here's the same query using db.select:
echo 'SELECT a_row AS GridRow, a_col AS GridCol, SUM(clip_area) As
"Water Area in Grid" FROM glwd_grid GROUP BY a_cat ORDER BY a_row, a_col
LIMIT 20;' | db.select
GridRow|GridCol|Water Area in Grid
9|43|11734990.811648
10|42|7600679.947002
10|43|20154750.823557
10|44|10095944.174832
10|46|18364623.744757
10|49|3054521.141835
11|41|250083.456892
11|42|9839134.964962
11|43|23519926.337785
11|44|11323614.28017
11|45|8426141.099425
11|46|12079532.459832
11|47|11135300.910967
11|49|571804.968053
11|50|1319664.199523
12|41|18036461.225015
12|42|15664405.025981
12|43|2471761.404269
12|45|2339714.549891
12|47|2890312.572311

So I got this now, but now I struggle with getting these summed values set
in at the right locations in the vector grid (or ideally a raster, which is
the ultimate goal).

I guess the idea is to create a new vector from the sql selection and then
rasterize this new map, but I am affraid I will have to ask for a hint once
again...

Thanks again
-Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005898.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Well this would be easy to do right within SQLite. After creating the grid in GRASS you’ll have an SQLite table called glwd_grid of all areas of water surface (clipped to the grid) and another table of the grid itself (I called it grid92 in the example). So, in SQLite: ALTER TABLE grid92 ADD COLUMN water_surf_area DOUBLE PRECISION; Then use the above query as a subquery in an UPDATE Statement: UPDATE grid92 SET water_surf_area=( SELECT SUM(clip_area) FROM glwd_grid AS gg WHERE gg.a_cat=grid92.cat ) ; That should leave you with a vector polygon layer “grid92” including a column “water_surf_area” which holds the area covered by water in each grid cell. To convert that to a raster, using the water surface area would require: extracting centroids, exporting the centroid attribute table to ascii, and using that with r.in.xyz to recreate the raster. v.extract grid92 type=centroids out=grid92_centroids # GRASS keeps the attrib table linked to the centroids, # so when you extract centroids you also get the attribs v.out.ascii grid92_centroids out=grid92_centroids.txt columns=“cat,water_surf_area,……” # Check the ascii file to see column positions Now set the resolution to exactly what you want for the final raster: g.region -p res=92000,92000 n=… s=… e=… w=… Use the r.in.xyz -s option to examine the extent of the xyz point data from the vector grid. Then r.in.xyz -s grid92_centroids.txt r.in.xyz in=grid92_centroids.txt out=grid92 z= The above seems a bit convoluted. Maybe someone else can see a more straight forward solution… Regards, Micha

···

On 02/10/2012 17:43, Lars Dalby wrote:

Micha Silver wrote

Here's the same query using db.select:
echo 'SELECT a_row AS GridRow, a_col AS GridCol, SUM(clip_area) As 
"Water Area in Grid" FROM glwd_grid GROUP BY a_cat ORDER BY a_row, a_col 
LIMIT 20;' | db.select
GridRow|GridCol|Water Area in Grid
9|43|11734990.811648
10|42|7600679.947002
10|43|20154750.823557
10|44|10095944.174832
10|46|18364623.744757
10|49|3054521.141835
11|41|250083.456892
11|42|9839134.964962
11|43|23519926.337785
11|44|11323614.28017
11|45|8426141.099425
11|46|12079532.459832
11|47|11135300.910967
11|49|571804.968053
11|50|1319664.199523
12|41|18036461.225015
12|42|15664405.025981
12|43|2471761.404269
12|45|2339714.549891
12|47|2890312.572311

So I got this now, but now I struggle with getting these summed values set
in at the right locations in the vector grid (or ideally a raster, which is
the ultimate goal).

I guess the idea is to create a new vector from the sql selection and then
rasterize this new map, but I am affraid I will have to ask for a hint once
again...

Thanks again
-Lars

--
View this message in context: [http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005898.html](http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5005898.html)
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[http://lists.osgeo.org/mailman/listinfo/grass-user](http://lists.osgeo.org/mailman/listinfo/grass-user)

This mail was received via Mail-SeCure System.

-- 
Micha Silver
052-3665918

Micha Silver wrote

    v.out.ascii grid92_centroids out=grid92_centroids.txt
    columns="cat,water_surf_area,...&lt;other data&gt;..."
    # Check the ascii file to see column positions

This returned this error message on my system: v.out.ascii(44851) malloc:
*** error for object 0x102013dc0: incorrect checksum for freed object -
object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Unable to really figure what was going on here I started to look for
alternatives to solve this last step.

So I ended up skipping the export and simply doing:

v.to.rast input=VectorGrid output=glwdFinalRast use=attr
attrcolumn=water_surf_area

Where VectorGrid = grid92 in your example.
As far as I can see, this actually works!

Thank you very much for your help and for staying with me to the bitter end!

Best,
Lars

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-tp5005264p5006172.html
Sent from the Grass - Users mailing list archive at Nabble.com.