[GRASS-user] r.buffer
Alessandro Bertan
alessandro.bertan at googlemail.com
Tue Oct 27 18:24:17 EDT 2009
Dear GRASS users,
I am a GRASS newbie, so I apologise in advance for the simplicity of
my question. I have a set of sites and I would like to create a series
of circular buffers around each site and then use r.stats to extract
some information from each buffer in combination with a land cover
map. My problem is that if I simply use the v.to.rast and r.buffer
commands to obtain the buffers, many of these will clash into each
other because the sites are too close. I was wondering whether there
is any script out there capable of creating buffers one at the time
starting from a set of sites and then using the r.stats command to
extract info from data layer. If not, I would be really happy if you
could point me in the right direction! I have found some code (see
below) that has proved useful, but does not do exactly what I want.
Basically, by starting from a set coordinates, the script is capable
of zooming into a region around each site and extracting the relevant
information using the r.stats command. Unfortunately I have no clue on
how to create the individual buffers. Any help would be appreciated!
thanks!
Alessandro
#!/bin/sh
#replace 'foo' with name of input file (easting and northing)
#replace 'outfile' with name of output file
#replace 'LCM2000a' with the name of the map from where you want to
extract some information
numSites=`wc -l foo | awk '{print $1}'`
winSize=500
for (( site=1 ; site <= $numSites ; site++ ));
do
cent_e=`awk '{if(NR=='$site') printf("%.0f", $1)}' foo`
cent_n=`awk '{if(NR=='$site') printf("%.0f", $2)}' foo`
echo POINT $site e=$cent_e n=$cent_n
nrth=`expr $cent_n + $winSize`
soth=`expr $cent_n - $winSize`
east=`expr $cent_e + $winSize`
west=`expr $cent_e - $winSize`
echo SITE $site n=$nrth s=$soth e=$east w=$west
g.region n=$nrth s=$soth e=$east w=$west res=25
d.erase
d.rast LCM2000a
r.stats -cn LCM2000a > hab.temp
awk '{print '$site', $0,$1}' hab.temp >> outfile
done
#g.region rast=LCM2000a
More information about the grass-user
mailing list