[GRASS-user] i.spectral and gnuplot

Hi

I'm trying to run i.spectral which of course requires gnuplot. I have gnuplot 4 installed (via fink) but i.spectral can't see it and asks for it to be installed. I made GRASS_GNUPLOT = /sw/bin but that didn't help. I'm running 6.1cvs on OSX 10.4.6. Any suggestions on how to make gnuplot visible to i.spectral would be much appreciated.

Stuart

Stuart Edwards wrote:

I'm trying to run i.spectral which of course requires gnuplot. I
have gnuplot 4 installed (via fink) but i.spectral can't see it and
asks for it to be installed. I made GRASS_GNUPLOT = /sw/bin but that
didn't help. I'm running 6.1cvs on OSX 10.4.6. Any suggestions on
how to make gnuplot visible to i.spectral would be much appreciated.

There is a gratuitous check for whether gnuplot is in the path:

  #check if present
  if [ ! -x "`which gnuplot`" ] ; then
      echo "$PROG: gnuplot required, please install first" 2>&1
      exit 1
  fi

Remove that check from the i.spectral script. It actully uses
$GRASS_GNUPLOT to invoke it.

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

Glynn, Hamish

Thanks for looking into it. Since I'm hooked on Lorenzo's binaries I'll have to wait for his next update.

Stuart
On Jun 24, 2006, at 10:00 AM, Glynn Clements wrote:

Stuart Edwards wrote:

I'm trying to run i.spectral which of course requires gnuplot. I
have gnuplot 4 installed (via fink) but i.spectral can't see it and
asks for it to be installed. I made GRASS_GNUPLOT = /sw/bin but that
didn't help. I'm running 6.1cvs on OSX 10.4.6. Any suggestions on
how to make gnuplot visible to i.spectral would be much appreciated.

There is a gratuitous check for whether gnuplot is in the path:

  #check if present
  if [ ! -x "`which gnuplot`" ] ; then
      echo "$PROG: gnuplot required, please install first" 2>&1
      exit 1
  fi

Remove that check from the i.spectral script. It actully uses
$GRASS_GNUPLOT to invoke it.

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

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

Stuart,

I don't know about Mac's binaries, but i.spectral is actually a script and it is accessible using any editor. Check your script folder in your grass distribution and remove the gnuplot check strings which Glynn pointed out.

Cheers,
Francesco

At 15.43 26/06/2006, you wrote:

Glynn, Hamish

Thanks for looking into it. Since I'm hooked on Lorenzo's binaries
I'll have to wait for his next update.

Stuart
On Jun 24, 2006, at 10:00 AM, Glynn Clements wrote:

Stuart Edwards wrote:

I'm trying to run i.spectral which of course requires gnuplot. I
have gnuplot 4 installed (via fink) but i.spectral can't see it and
asks for it to be installed. I made GRASS_GNUPLOT = /sw/bin but that
didn't help. I'm running 6.1cvs on OSX 10.4.6. Any suggestions on
how to make gnuplot visible to i.spectral would be much appreciated.

There is a gratuitous check for whether gnuplot is in the path:

        #check if present
        if [ ! -x "`which gnuplot`" ] ; then
            echo "$PROG: gnuplot required, please install first" 2>&1
            exit 1
        fi

Remove that check from the i.spectral script. It actully uses
$GRASS_GNUPLOT to invoke it.

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

_______________________________________________
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

Francesco

Ok -- that was straight forward (in the grand scheme of things) -- thanks. Now when I run i.spectral the following error is returned:

line 229: gnuplot: command not found

Is this a path problem on my part or something in the script? Is $GNUPLOT (from line 229) the same as GRASS_GNUPLOT (the environmental variable)? Wish I knew more about this! Thanks for any advice.

Stuart
On Jun 26, 2006, at 12:00 PM, francesco wrote:

Stuart,

I don't know about Mac's binaries, but i.spectral is actually a script and it is accessible using any editor. Check your script folder in your grass distribution and remove the gnuplot check strings which Glynn pointed out.

Cheers,
Francesco

At 15.43 26/06/2006, you wrote:

Glynn, Hamish

Thanks for looking into it. Since I'm hooked on Lorenzo's binaries
I'll have to wait for his next update.

Stuart
On Jun 24, 2006, at 10:00 AM, Glynn Clements wrote:

Stuart Edwards wrote:

I'm trying to run i.spectral which of course requires gnuplot. I
have gnuplot 4 installed (via fink) but i.spectral can't see it and
asks for it to be installed. I made GRASS_GNUPLOT = /sw/bin but that
didn't help. I'm running 6.1cvs on OSX 10.4.6. Any suggestions on
how to make gnuplot visible to i.spectral would be much appreciated.

There is a gratuitous check for whether gnuplot is in the path:

        #check if present
        if [ ! -x "`which gnuplot`" ] ; then
            echo "$PROG: gnuplot required, please install first" 2>&1
            exit 1
        fi

Remove that check from the i.spectral script. It actully uses
$GRASS_GNUPLOT to invoke it.

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

_______________________________________________
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

Stuart Edwards wrote:

Now when I run i.spectral the following error is returned:

line 229: gnuplot: command not found

Is this a path problem on my part or something in the script? Is
$GNUPLOT (from line 229) the same as GRASS_GNUPLOT (the
environmental variable)? Wish I knew more about this! Thanks for
any advice.

? I don't see a $GNUPLOT at or near line 229 in any version.
what does line 229 look like?

can you try using the latest CVS version?

http://freegis.org/cgi-bin/viewcvs.cgi/*checkout*/grass6/scripts/i.spectral/i.spectral?rev=HEAD&content-type=text/plain

before you start the GRASS from a terminal shell, or placed in
.grass.bashrc have you set (assuming you use Bash and not Csh)

GRASS_GNUPLOT=/sw/wherever/gnuplot/is/gnuplot
export GRASS_GNUPLOT

?

Hamish

Can you access gnuplot from the unix bash by typing "gnuplot"? Probably not since it gives that line 229 error. I don't know about Mac, but either you have gnuplot installed as mac binary and not accessible by the unix shell, or you have a different name. Try installing gnuplot unix binaries.
Francesco Pirotti

At 04.18 27/06/2006, Stuart Edwards wrote:

Francesco

Ok -- that was straight forward (in the grand scheme of things) --
thanks. Now when I run i.spectral the following error is returned:

line 229: gnuplot: command not found

Is this a path problem on my part or something in the script? Is
$GNUPLOT (from line 229) the same as GRASS_GNUPLOT (the
environmental variable)? Wish I knew more about this! Thanks for
any advice.

Stuart
On Jun 26, 2006, at 12:00 PM, francesco wrote:

Stuart,

I don't know about Mac's binaries, but i.spectral is actually a
script and it is accessible using any editor. Check your script
folder in your grass distribution and remove the gnuplot check
strings which Glynn pointed out.

Cheers,
Francesco

At 15.43 26/06/2006, you wrote:

Glynn, Hamish

Thanks for looking into it. Since I'm hooked on Lorenzo's binaries
I'll have to wait for his next update.

Stuart
On Jun 24, 2006, at 10:00 AM, Glynn Clements wrote:

Stuart Edwards wrote:

I'm trying to run i.spectral which of course requires gnuplot. I
have gnuplot 4 installed (via fink) but i.spectral can't see it and
asks for it to be installed. I made GRASS_GNUPLOT = /sw/bin but
that
didn't help. I'm running 6.1cvs on OSX 10.4.6. Any suggestions on
how to make gnuplot visible to i.spectral would be much
appreciated.

There is a gratuitous check for whether gnuplot is in the path:

        #check if present
        if [ ! -x "`which gnuplot`" ] ; then
            echo "$PROG: gnuplot required, please install first"
2>&1
            exit 1
        fi

Remove that check from the i.spectral script. It actully uses
$GRASS_GNUPLOT to invoke it.

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

_______________________________________________
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

Hamish, Francesco

After fearing for my sanity, I think I may have found the problem. The script in Lorenzo's binary distribution is not the same as the one that you pointed me to in spite of identical headers. Attached 'i.spectral' is from the distribution, 'i.spectral2' is the script at
  <http://freegis.org/cgi-bin/viewcvs.cgi/*checkout*/grass6/scripts/i.spectral/i.spectral?rev=HEAD&content-type=text/plain&gt;
The differences start at about line 51.

Tomorrow I'll have a crack at this again using the correct version! Gnuplot does open on command from the shell and GRASS_GNUPLOT = /sw/bin/gnuplot.

Regards

Stuart

(attachments)

i.spectral (1.5 KB)
i.spectral (4.96 KB)
i.spectral2 (1.5 KB)
i.spectral2 (5.6 KB)

Stuart Edwards wrote:

After fearing for my sanity, I think I may have found the problem.
The script in Lorenzo's binary distribution is not the same as the
one that you pointed me to in spite of identical headers. Attached
'i.spectral' is from the distribution, 'i.spectral2' is the script at
  <http://freegis.org/cgi-bin/viewcvs.cgi/*checkout*/grass6/scripts/
i.spectral/i.spectral?rev=HEAD&content-type=text/plain>
The differences start at about line 51.

you seem to have a version older than 11 May. here is the history:

http://freegis.org/cgi-bin/viewcvs.cgi/grass6/scripts/i.spectral/i.spectral

Tomorrow I'll have a crack at this again using the correct version!
Gnuplot does open on command from the shell and GRASS_GNUPLOT = /sw/
bin/gnuplot.

try

GRASS_GNUPLOT="/sw/bin/gnuplot -persist"
export GRASS_GNUPLOT
i.spectral

if /sw/bin/ is in your $PATH, then you don't need any of this.
does "which gnuplot" work from the terminal prompt?

perhaps add to ~/.grass.bashrc:

GRASS_ADDON_PATH=/sw/bin
export GRASS_ADDON_PATH

Hamish

What is the chance that i.spectral could use the new, expanded d.graph
instead of gnuplot for this? I haven't looked at the script, but this would
allow it to run without an external dependency.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Stuart Edwards <sedwards2@cinci.rr.com>
Date: Wed, 28 Jun 2006 00:52:13 -0400
To: Hamish <hamish_nospam@yahoo.com>
Cc: <grassuser@grass.itc.it>
Subject: Re: [GRASS-user] i.spectral and gnuplot

Hamish, Francesco

After fearing for my sanity, I think I may have found the problem.
The script in Lorenzo's binary distribution is not the same as the
one that you pointed me to in spite of identical headers. Attached
'i.spectral' is from the distribution, 'i.spectral2' is the script at
  <http://freegis.org/cgi-bin/viewcvs.cgi/*checkout*/grass6/scripts/
i.spectral/i.spectral?rev=HEAD&content-type=text/plain>
The differences start at about line 51.

Tomorrow I'll have a crack at this again using the correct version!
Gnuplot does open on command from the shell and GRASS_GNUPLOT = /sw/
bin/gnuplot.

Regards

Stuart

On Jun 26, 2006, at 10:58 PM, Hamish wrote:

Stuart Edwards wrote:

Now when I run i.spectral the following error is returned:

line 229: gnuplot: command not found

Is this a path problem on my part or something in the script? Is
$GNUPLOT (from line 229) the same as GRASS_GNUPLOT (the
environmental variable)? Wish I knew more about this! Thanks for
any advice.

? I don't see a $GNUPLOT at or near line 229 in any version.
what does line 229 look like?

can you try using the latest CVS version?

http://freegis.org/cgi-bin/viewcvs.cgi/*checkout*/grass6/scripts/
i.spectral/i.spectral?rev=HEAD&content-type=text/plain

before you start the GRASS from a terminal shell, or placed in
.grass.bashrc have you set (assuming you use Bash and not Csh)

GRASS_GNUPLOT=/sw/wherever/gnuplot/is/gnuplot
export GRASS_GNUPLOT

?

Hamish

Thanks to the efforts of Bejamin Ducke, I now have r.cva installed. However, it does not take a single point as the target, but requires a binary raster map containing either targets or viewpoints. I read the wiki and did some googling, but can't find out how to build such a map.

If QGIS can do this, I have it installed. I can generate a GPX file if that helps.

Hamish, Francesco

Back on this. Thanks for the tips. All were spot on. Now just a little (?) glitch in the execution. Script executes as it should if a 'group' is used. However if a list of rasters is used instead, the following errors occur:

GRASS 6.1.cvs (locationA):~ > i.spectral raster=AST6,AST7,AST8 -i
csh: if: Malformed file inquiry.

Click mouse button on desired location

              EAST: NORTH:
       748730.21875 3969381.53125 1
paste: data.dum: No such file or directory

gnuplot> set xtics ()
                     ^
          "spectrum.gnuplot", line 1: invalid expression

This looks like it could be a Rev 1.6 issue since that's when it first became possible to use a group instead of the raster list.

Thanks again. Much learned!
Stuart

On Jun 28, 2006, at 3:23 AM, Hamish wrote:

Stuart Edwards wrote:

After fearing for my sanity, I think I may have found the problem.
The script in Lorenzo's binary distribution is not the same as the
one that you pointed me to in spite of identical headers. Attached
'i.spectral' is from the distribution, 'i.spectral2' is the script at
  <http://freegis.org/cgi-bin/viewcvs.cgi/*checkout*/grass6/scripts/
i.spectral/i.spectral?rev=HEAD&content-type=text/plain>
The differences start at about line 51.

you seem to have a version older than 11 May. here is the history:

http://freegis.org/cgi-bin/viewcvs.cgi/grass6/scripts/i.spectral/i.spectral

Tomorrow I'll have a crack at this again using the correct version!
Gnuplot does open on command from the shell and GRASS_GNUPLOT = /sw/
bin/gnuplot.

try

GRASS_GNUPLOT="/sw/bin/gnuplot -persist"
export GRASS_GNUPLOT
i.spectral

if /sw/bin/ is in your $PATH, then you don't need any of this.
does "which gnuplot" work from the terminal prompt?

perhaps add to ~/.grass.bashrc:

GRASS_ADDON_PATH=/sw/bin
export GRASS_ADDON_PATH

Hamish

Stuart Edwards wrote:

Back on this. Thanks for the tips. All were spot on. Now just a
little (?) glitch in the execution. Script executes as it should if
a 'group' is used. However if a list of rasters is used instead, the
following errors occur:

GRASS 6.1.cvs (locationA):~ > i.spectral raster=AST6,AST7,AST8 -i
csh: if: Malformed file inquiry.

Can you try changing the "#!/bin/sh" at the start to "#!/bin/sh -x"?
That should provide more information on exactly where it's failing.

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

ok -- here's the verbose version (looks like data.dum gets removed shortly before it is called for 'paste'):

GRASS 6.1.cvs (locationA):~ > i.spectral raster=AST6,AST7,AST8,AST9 -i
+ test /Applications/GRASS/grass61cvs.app/Contents/Resources/grass-6.1.cvs = ''
+ PARAM_NUM=2
+ '[' raster=AST6,AST7,AST8,AST9 '!=' @ARGS_PARSED@ ']'
+ exec g.parser /Applications/GRASS/grass61cvs.app/Contents/Resources/grass-6.1.cvs/scripts/i.spectral raster=AST6,AST7,AST8,AST9 -i
+ test /Applications/GRASS/grass61cvs.app/Contents/Resources/grass-6.1.cvs = ''
+ PARAM_NUM=1
+ '[' @ARGS_PARSED@ '!=' @ARGS_PARSED@ ']'
++ which /sw/bin/gnuplot -persist
csh: if: Malformed file inquiry.
+ '[' '!' -x /sw/bin/gnuplot ']'
++ which awk
+ '[' '!' -x /usr/bin/awk ']'
+ unset LC_ALL
+ export LC_NUMERIC=C
+ LC_NUMERIC=C
++ g.tempfile pid=1938
+ TMP1=/Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.0
++ g.tempfile pid=1938
+ TMP2=/Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.1
+ xlabels=
+ '[' '!' '' ']'
+ '[' 1 -eq 0 ']'
+ RASTERMAPS=
++ echo
++ sed 's+,+ +g'
+ news=
+ as=0
+ NUMBANDS=0
+ rm -f /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.1
+ '[' 0 -eq 0 ']'
++ d.mon -L
++ grep -v 'not running'
++ wc -l
++ awk '{print $1}'
+ '[' 3 -eq 2 ']'
+ d.where -1
+ r.what input=

Click mouse button on desired location

              EAST: NORTH:
  748435.03125 4969971.90625 1
+ cc=0
++ cat /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.0
++ sed 's+\*+0+g'
++ sed 's+|+ +g'
+ TT=748435.03125 4969971.90625 1
++ cat /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.0
++ wc -l
+ NUMCLICKS= 1
+ START=0
++ cat /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.0
++ expr 0 + 1
+ START=1
++ echo '748435.03125|4969971.90625|1'
++ cut '-d|' -f1,2
++ tr '|' ' '
+ COORD[$START]=748435.03125 4969971.90625
++ echo '748435.03125|4969971.90625|1'
++ sed 's+\*+0+g'
++ sed 's+|+ +g'
+ TOT=748435.03125 4969971.90625 1
+ cc=0
++ expr 0 + 1
+ cc=1
+ '[' 1 -gt 3 ']'
++ expr 1 + 1
+ cc=2
+ '[' 2 -gt 3 ']'
++ expr 2 + 1
+ cc=3
+ '[' 3 -gt 3 ']'
+ rm -f /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.0
+ NUM=0
++ expr 0 / 1
+ NUM2=0
++ expr 0 + 1
+ NUM2=1
+ rm -f data.dum
+ i=0
+ '[' 0 '!=' 0 ']'
+ r=0
+ '[' 0 '!=' 1 ']'
++ expr 0 + 1
+ r=1
+ paste '-d ' data.dum /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.1_1
paste: data.dum: No such file or directory
+ rm -f /Users/stu/grassdata/locationA/stu/.tmp/SEsG4iBook.local/1938.1_1
+ '[' 1 '!=' 1 ']'
++ expr 0 + 1
+ xrange=1
+ echo 'set xtics ()'
+ echo 'set grid'
+ echo 'set title '\''Spectral signatures'\'''
+ echo 'set xrange [0:1]'
+ echo 'set noclabel'
+ echo 'set xlabel '\''Bands'\'''
+ echo 'set ylabel '\''DN Value'\'''
+ echo 'set data style lines'
+ rm -f data.dum
+ i=0
+ str=
+ '[' 0 '!=' 1 ']'
++ expr 0 + 1
+ i=1
+ '[' 1 -eq 1 ']'
+ '[' 0 -eq 0 ']'
+ str=plot 'data_1' title '1'
+ '[' 1 '!=' 1 ']'
+ str=plot 'data_1' title '1' with linespoints pt 779
+ echo plot ''\''data_1'\''' title ''\''1'\''' with linespoints pt 779
+ /sw/bin/gnuplot -persist spectrum.gnuplot

gnuplot> set xtics ()
                     ^
          "spectrum.gnuplot", line 1: invalid expression

+ i=0
+ '[' 0 '!=' 1 ']'
++ expr 0 + 1
+ i=1
+ rm -f data_1
+ '[' 1 '!=' 1 ']'
+ rm -f spectrum.gnuplot

Stuart
_________________

On Jul 12, 2006, at 12:09 AM, Glynn Clements wrote:

Stuart Edwards wrote:

Back on this. Thanks for the tips. All were spot on. Now just a
little (?) glitch in the execution. Script executes as it should if
a 'group' is used. However if a list of rasters is used instead, the
following errors occur:

GRASS 6.1.cvs (locationA):~ > i.spectral raster=AST6,AST7,AST8 -i
csh: if: Malformed file inquiry.

Can you try changing the "#!/bin/sh" at the start to "#!/bin/sh -x"?
That should provide more information on exactly where it's failing.

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

Hello all,

It was a fat bug, my error, as expected ... I attach the fixed version of i.spectral (for the fast and furious), put it into your scripts folder... I'll have someone update the cvs...

Let me know if all goes well with this version, I just have little time for testing.

Cheers,
Francesco Pirotti

(attachments)

i.spectral (5.63 KB)

Hi

Getting close -- the new version contains the 'gratuitous' check for gnuplot identified by Glynn 6/24. With lines 52 -55 commented out though, it runs fine. Thanks for your help.
Stuart
______________
On Jul 12, 2006, at 10:48 AM, francesco wrote:

Hello all,

It was a fat bug, my error, as expected ... I attach the fixed version of i.spectral (for the fast and furious), put it into your scripts folder... I'll have someone update the cvs...

Let me know if all goes well with this version, I just have little time for testing.

Cheers,
Francesco Pirotti
<i.spectral>

francesco wrote:

It was a fat bug, my error, as expected ... I attach the fixed version of
i.spectral (for the fast and furious), put it into your scripts folder...
I'll have someone update the cvs...

I've committed the part that fixes the variable name (GIS_OPT_RASTER).

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

gary wrote:

Thanks to the efforts of Bejamin Ducke, I now have r.cva installed.
However, it does not take a single point as the target, but requires a
binary raster map containing either targets or viewpoints. I read the
wiki and did some googling, but can't find out how to build such a
map.

r.mapcalc "map=if(a, b, c)"

read: if (a) then "b", otherwise "c".

see the r.mapcalc help page.

Hamish