[GRASSLIST:747] Re: Getting the bounds of features

Dylan Beaudette dylan.beaudette at gmail.com
Tue Apr 18 12:59:37 EDT 2006


On Tuesday 18 April 2006 06:26 am, Sudipta Sarkar wrote:
> Hi Guys,
> How do i get the minimum bounding rectangle coordinates of each feature
> within grass?  I need  to get the UL, UR, LL and LR X and Y coordinates of
> each feature within a feature class and be able to summarize based on each
> of these x and y coordinates. So it will be like how many times same ULX is
> repeated, how many times same ULY is repeated etc. Any help will be
> appreciated.
> Thanks
>

interesting question.

a simple way to do this would be with a for() loop in bash, assumming that 
each of your features has topology and a CAT value.

make a list of cat values for a given vector:

#complicated vector with overlapping polys, your vector might be simpler
cats=`v.category geo option=print | sort -g | grep -v "/" | uniq`

#loop through these values

for x in $cats
do
#extract each feature by cat value
v.extract in=geo list=$x out=geo_$x
#zoom to the region bounding this feature and save the output for processing
g.region vect=geo_$x > region_geo_$x.txt
#cleanup g.remove vect=geo_$x

#rinse and repeat
done


-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341




More information about the grass-user mailing list