[GRASSLIST:1469] Re: GRID-one step ahead

Hamish hamish_nospam at yahoo.com
Sat Oct 11 23:08:36 EDT 2003


>  I have laid the grids on my raster map by d.grid. I am
> facing two two problems. d.grid had parameters like:
> d.grid size=value [color=name] [origin=easting,northing]
> 
> 1. What is the use of [origin=easting,northing]. Even if I mention a 
> particular lat-long value (eg. 25,70), the grid overlays in the whole
> map irrespective of the lat-long values mentioned by me and the
> same thing happens if I don't mention any value in the origin (i:e.
> the grid is overlayed in the whole map).

origin=easting,northing mearly shifts the grid in x,y space, it doesn't
create a bounded grid. For that you might want to try v.mkgrid.


> 2. I want to calculate the number of pixels falling to a particular
> category say water,forest,agriculture etc. in each grid. How should I
> proceed to begin with a single grid and eventually covering all the
> grids in the area of interest.


A way this could be done is with a bash script.

That might look something like:

g.region rast=raster_map   # (for resolution)

for ROW in 1 2 3 4 ... ; do
  NORTH=<figure out north bound from $ROW number> 
  SOUTH=<figure out south bound from $ROW number> 
  for COL in 1 2 3 4 ... ; do
    EAST=<figure out east bound from $COL number> 
    WEST=<figure out west bound from $COL number> 
    g.region n=$NORTH s=$SOUTH w=$WEST e=$EAST
    r.report [options] > stats-grid_$ROW.$COL.txt
  done
done

If there are only a few boxes you could do this by hand of course.

although there may be a better way...
v.mkquads may give some ideas also.



Hamish




More information about the grass-user mailing list