[GRASS-user] min and max coord values

hello

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 ?

regards

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

"t" == temiz <temiz@deprem.gov.tr> writes:

t> I want to get min and max coord values from of catagorized raster
t> map.

t> something like: r.stats -agn hey6 > gives minx maxx miny maxy

t> is it possible ?

        You may use r.info to obtain the coordinates of the opposite
        corners of the grid of the raster map. Alternatively, you could
        change the current region to the one of the raster map ($
        g.region rast=MAP), then print it ($ g.region -p.) (You're to
        save the current region to a temporary file to be able to return
        to it.)

        The above gives you the coordinates of the corners of the grid.
        I know no easy way to obtain the coordinates of the corners of
        the actual data (i. e., with the NULLs omitted.)

Ivan Shmakov wrote:

>>>>> "t" == temiz <temiz@deprem.gov.tr> writes:

t> I want to get min and max coord values from of catagorized raster
t> map.

t> something like: r.stats -agn hey6 > gives minx maxx miny maxy

t> is it possible ?

        You may use r.info to obtain the coordinates of the opposite
        corners of the grid of the raster map. Alternatively, you could
        change the current region to the one of the raster map ($
        g.region rast=MAP), then print it ($ g.region -p.) (You're to
        save the current region to a temporary file to be able to return
        to it.)

        The above gives you the coordinates of the corners of the grid.
        I know no easy way to obtain the coordinates of the corners of
        the actual data (i. e., with the NULLs omitted.)

You can use "g.region zoom=..." for this.

The rast= option uses the bounds of the map itself, while zoom= uses
the smallest rectangle which encloses all of the non-null cells.

--
Glynn Clements <glynn@gclements.plus.com>

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='.

?
Hamish

Hamish wrote:

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='.

?
Hamish

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?

As far as I see, g.region gives only perpendicular bounding box.

regards

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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@gclements.plus.com>

(attachments)

bbox.awk (265 Bytes)

Glynn Clements wrote:

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

  ------------------------------------------------------------------------

#!/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]
}
  

Thank you again

I preferred r.stats, because its output more is manageable than g.region's in terms of querying.
The awk script solved the issue practically.
I was thinking to port the data to postgresql to find min, max coord values for each category.

By the way just an idea:

can "g.region zoom=" work with respect to cat value of a map in grass's future releases ?

regards

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

temiz wrote:

can "g.region zoom=" work with respect to cat value of a map in grass's
future releases ?

You can achieve the same result with a combination of r.reclass and
g.region.

--
Glynn Clements <glynn@gclements.plus.com>