[GRASS-user] Spatial Statistics

Hallo all,

is there a possibility to extract statistics from a raster map delimiting it by a vector map?
I mean, without converting it to a raster map.

Thank you!

Manuel (discovering now the vector features!)

--
Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universität Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/

On Wed, Mar 07, 2007 at 11:32:19AM +0100, Dr. Manuel Seeger wrote:

Hallo all,

is there a possibility to extract statistics from a raster map
delimiting it by a vector map?
I mean, without converting it to a raster map.

Thank you!

Manuel,

v.rast.stats is your friend:

v.rast.stats - Calculates univariate statistics from a GRASS raster map based on vector objects
http://grass.itc.it/grass63/manuals/html63_user/v.rast.stats.html

Hope this helps,
Markus

Markus Neteler schrieb:

Manuel,

v.rast.stats is your friend:

v.rast.stats - Calculates univariate statistics from a GRASS raster map based on vector objects
http://grass.itc.it/grass63/manuals/html63_user/v.rast.stats.html

Hope this helps,
Markus
  

Thank you!
It works.
But not really clean.
if I try to let the module add the colums by itself, it creates an eroor after the first column, retrying it goes on and stops at the second etc. so I have to repeat the procedure. The problem is, that on this way, it leaves temporary raster files within my mapset in use for every step...

Please excuse, but I dind not copy the error echo.

Perhaps someone may reproduce it?

Again, thanks a lot!

Manuel

--
Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universität Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/

Manuel,

You might check out starspan (http://starspan.casil.ucdavis.edu/) which is designed specifically for this purpose and works well with GRASS rasters.

  • matt

On 3/7/07, Dr. Manuel Seeger <seeger@uni-trier.de> wrote:

Hallo all,

is there a possibility to extract statistics from a raster map
delimiting it by a vector map?
I mean, without converting it to a raster map.

Thank you!

Manuel (discovering now the vector features!)


Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universität Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/


grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser


Matthew T. Perry
http://www.perrygeo.net

On Wed, Mar 07, 2007 at 06:38:09PM +0100, Dr. Manuel Seeger wrote:

Markus Neteler schrieb:
>
>Manuel,
>
>v.rast.stats is your friend:
>
> v.rast.stats - Calculates univariate statistics from a GRASS raster map
> based on vector objects
> http://grass.itc.it/grass63/manuals/html63_user/v.rast.stats.html
>
>Hope this helps,
>Markus
>
Thank you!
It works.
But not really clean.
if I try to let the module add the colums by itself, it creates an eroor
after the first column, retrying it goes on and stops at the second etc.

Which error actually?

so I have to repeat the procedure. The problem is, that on this way, it
leaves temporary raster files within my mapset in use for every step...

This should not happen of course.
I see that an empty file is left behind, will check.

Please excuse, but I dind not copy the error echo.

Perhaps someone may reproduce it?

I just tried the example from the manual page, no problem.

Please tell us
- which error
- which GRASS version
- which operating system

Markus

Again, thanks a lot!

Manuel

--
Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universit?t Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

My $.02

I have used the v.rast.stats command many times with much success.
Though, I have to admit, I still haven't graduated to GRASS 6.X yet. I
used 5.4 and it worked with no problems whatsoever.

Kevin Slover
Coastal / GIS Specialist
2872 Woodcock Blvd Suite 230
Atlanta GA 30341
(P) 678-530-0022
(F) 678-530-0044

-----Original Message-----
From: grassuser-bounces@grass.itc.it
[mailto:grassuser-bounces@grass.itc.it] On Behalf Of Markus Neteler
Sent: Wednesday, March 07, 2007 2:44 PM
To: GRASSLIST
Subject: Re: [GRASS-user] Spatial Statistics

On Wed, Mar 07, 2007 at 06:38:09PM +0100, Dr. Manuel Seeger wrote:

Markus Neteler schrieb:
>
>Manuel,
>
>v.rast.stats is your friend:
>
> v.rast.stats - Calculates univariate statistics from a GRASS raster

map

> based on vector objects
> http://grass.itc.it/grass63/manuals/html63_user/v.rast.stats.html
>
>Hope this helps,
>Markus
>
Thank you!
It works.
But not really clean.
if I try to let the module add the colums by itself, it creates an

eroor

after the first column, retrying it goes on and stops at the second

etc.

Which error actually?

so I have to repeat the procedure. The problem is, that on this way,

it

leaves temporary raster files within my mapset in use for every

step...

This should not happen of course.
I see that an empty file is left behind, will check.

Please excuse, but I dind not copy the error echo.

Perhaps someone may reproduce it?

I just tried the example from the manual page, no problem.

Please tell us
- which error
- which GRASS version
- which operating system

Markus

Again, thanks a lot!

Manuel

--
Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universit?t Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

Visit Dewberry's website at www.dewberry.com

This email transmission may contain confidential or privileged information. If you receive this email message in error, notify the sender by email and delete the email without reading, copying or disclosing the email contents. The unauthorized use or dissemination of any confidential or privileged information contained in this email is prohibited. If you are not the intended recipient and intentionally intercept or forward this message to someone else, you may be subject to criminal and/or civil penalties. See 18 U.S.C. 2511 et seq.

I am trying to serve grass files through mapserver. I have been following the instructions at:

http://grass.gdf-hannover.de/wiki/GRASS_and_MapServer

I have successfully in served grass raster files, but not grass vector files. If I try and use an HTML initialization file, nothing appears. If try to do it using a python mapscript I get a glibc error. The layer information, for the vector file, in my .map file is:

LAYER
     NAME "roads"
     TYPE line
     STATUS on
     CONNECTIONTYPE OGR
     CONNECTION "/var/www/html/mapserver/grassdata/MDI/PERMANENT/vector/roads/head"
     DATA "1" # Layer number
     CLASS
         NAME "roads"
         COLOR 250 100 0
     END
END

I checked the layer number in the dbln file, and it is:

1 roads cat $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/ dbf

so "1" looks correct. If I run ogrinfo on the header file, I get:

ogrinfo -ro -so /var/www/html/mapserver/grassdata/MDI/PERMANENT/vector/roads/head
Warning 1: GRASS warning: GISBASE environment variable was not set, using:
/usr/local/grass-6.2.0
INFO: Open of `/var/www/html/mapserver/grassdata/MDI/PERMANENT/vector/roads/head'
      using driver `GRASS' successful.
1: 1 (Line String)

Could the GISBASE warning be my problem? If so how do I set this variable, so ogr and mapserver can access it? I have tried the usual setenv, and even hard coded the path in the dbln file, but had the same problems.

Thanks
Jim

Hello all

Please tell us
- which error
  

The error is caused when I try to add the columns by v.rast.stats. This is what it gives as report. I run it by gui:

Adding column <DGM_n>
/usr/lib/grass/scripts/v.db.addcol: 96: let: not found
DBMI-DBF driver error:
Column 'DGM_n' already exists (duplicate name)
Cannot add column.
Error in db_execute_immediate()

Error while executing: "ALTER TABLE Kyll_fluss_100 ADD COLUMN DGM_n double precision
"
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue (problem to add column).

- which GRASS version
  

I'm running grass 6.2.1

- which operating system
  

On an ubuntu edgy with gnome

Another thing I noticed is that it does not work if vector file and table have different names (I dind not forget to connect the tables;-))

Greetings from the fog here
And thanks

Manuel

--
Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universität Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/

Dr. Manuel Seeger wrote on 03/08/2007 08:31 AM:

Hello all

Please tell us
- which error
  

The error is caused when I try to add the columns by v.rast.stats.
This is what it gives as report. I run it by gui:

Adding column <DGM_n>
/usr/lib/grass/scripts/v.db.addcol: 96: let: not found

I have fixed that - "let" is a bash command but not shell.
Change line 96 (where the "let" is) to
   n=`expr $n + 1`

DBMI-DBF driver error:
Column 'DGM_n' already exists (duplicate name)
Cannot add column.

Could you do a
v.info -c yourmap
?

Error in db_execute_immediate()

Error while executing: "ALTER TABLE Kyll_fluss_100 ADD COLUMN DGM_n
double precision
"
ERROR: Cannot continue (problem adding column).
ERROR: Cannot continue (problem to add column).

- which GRASS version
  

I'm running grass 6.2.1

- which operating system
  

On an ubuntu edgy with gnome

Strange that "let" fails - I would expect that from Windows only. Anyway,
should be fixed now.

Another thing I noticed is that it does not work if vector file and
table have different names (I dind not forget to connect the tables;-))

Sigh :slight_smile: I have to look into this, too.
Please let us know if at least the "let" problem is solved.

Cheers
Markus

Dr. Manuel Seeger:
> The error is caused when I try to add the columns by v.rast.stats.

Markus:

I have fixed that - "let" is a bash command but not shell.
Change line 96 (where the "let" is) to
   n=`expr $n + 1`

grep in the scripts/ dir shows that d.vect.thematic uses "let" a lot.
All other scripts apear to be clean. I don't use the module & thus can
not test it well, so I haven't committed a fix.

> I'm running grass 6.2.1
> On an ubuntu edgy with gnome

Strange that "let" fails - I would expect that from Windows only.

Ubuntu edgy is using [d]ash as #!/bin/sh not bash. So any bashisms will
cause an error. See earlier thread about r.tileset problems: (bug#5499)
  http://thread.gmane.org/gmane.comp.gis.grass.devel/18436/focus=18450

Hamish

Hello Markus and all the others,

I have fixed that - "let" is a bash command but not shell.
Change line 96 (where the "let" is) to
   n=`expr $n + 1`

I changed this in v.db.addcol and it behaves somehow strange, but now it works....:
it creates the table, it seems to calculate right, but gives this echo:
Adding column <dgm_n>
[: 96: expr 1+1: bad number
Adding column <dgm_min>
[: 96: expr 1+1: bad number
Adding column <dgm_max>
[: 96: expr 1+1: bad number
Adding column <dgm_range>
[: 96: expr 1+1: bad number
Adding column <dgm_mean>
[: 96: expr 1+1: bad number
Adding column <dgm_stddev>
[: 96: expr 1+1: bad number
Adding column <dgm_varian>
[: 96: expr 1+1: bad number
Adding column <dgm_cf_var>
[: 96: expr 1+1: bad number
Adding column <dgm_sum>
[: 96: expr 1+1: bad number
Processing category 317 (1/4)
Processing category 319 (2/4)
Processing category 322 (3/4)
Processing category 2147483647 (4/4)
Statistics calculated from raster map <Kyll_DGM_filled> and
uploaded to attribute table of vector map <Kyll_Pegel_EZGclean>.
Done.

the temp_file is still not removed from my mapset

DBMI-DBF driver error:
Column 'DGM_n' already exists (duplicate name)
Cannot add column.
    
Could you do a
v.info -c yourmap
?
  

The thing is, that the script added stepwise the columns. first the *_n, brek, then the next etc.
But now, it works, even with the error messages...

Thanks a lot!
Manuel

--
Dr. Manuel Seeger
Wiss. Assistent Scientific Assistant
Physische Geographie Dpt. of Physical Geography
FB VI - Geographie/Geowissenschaften Geography/Geosciences
Universität Trier University of Trier
D - 54286 Trier
Tel.: +49-651-201 4557
Fax: +49-651-201 3976
Web: http://www.uni-trier.de/uni/fb6/geographie/mitarbeiter/Seeger/

Dr. Manuel Seeger wrote:

> I have fixed that - "let" is a bash command but not shell.
> Change line 96 (where the "let" is) to
> n=`expr $n + 1`
>

I changed this in v.db.addcol and it behaves somehow strange, but now it
works....:
it creates the table, it seems to calculate right, but gives this echo:
Adding column <dgm_n>
[: 96: expr 1+1: bad number

You must have spaces around the "+" sign:

  $ expr 1 + 1
  2
  $ expr 1+1
  1+1

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