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

Lars Dalby lars.dalby at gmail.com
Sat Sep 29 13:40:58 PDT 2012


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?
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.


More information about the grass-user mailing list