[GRASS-user] min and max coord values
Glynn Clements
glynn at gclements.plus.com
Thu Jul 19 12:08:50 EDT 2007
temiz wrote:
> >> I want to get min and max coord values from of catagorized raster
> >> map.
> >>
> >> something like: r.stats -agn hey6 > gives minx maxx miny maxy
> >> is it possible ?
> >>
> >
> >
> > do you mean you want the coordinates of the bounding boxes surrounding
> > each category?
> >
> > loop over each CAT (`r.describe`), create a MASK or new map based on
> > that cat, then 'g.region -p zoom='.
>
> thank you and other friends
>
> I wrote a script to calculate the coordinates of bounding box of each
> category using "g.region -p zoom="
>
> I am wondering if "r.stats -agn" is second alternative ?
>
> My raster map is something like some islands.
> if I get coord value of each category , I can calculate most north-
> south and, most west- east, and then determine the coords of minimum
> bounding box?
This is more efficient, particularly for many categories, but it
requires a bit more work. The attached script takes the output from
"r.stats -gn" and computes the bounding boxes for each category, e.g.:
r.stats -gn fields | ./bbox.awk | sort -n
--
Glynn Clements <glynn at gclements.plus.com>
-------------- next part --------------
#!/usr/bin/awk -f
{
if ($3 in n)
{
if (n[$3] < $2) n[$3] = $2
if (s[$3] > $2) s[$3] = $2
if (e[$3] < $1) e[$3] = $1
if (w[$3] > $1) w[$3] = $1
}
else
{
n[$3] = s[$3] = $2
e[$3] = w[$3] = $1
}
}
END {
for (i in e)
print i,n[i],s[i],e[i],w[i]
}
More information about the grass-user
mailing list