S-plus

mike camann camann at pick.uga.edu
Sun Apr 30 12:59:21 EDT 1995


I too use S-plus and GRASS together, and I already find that
integrating them is so easy that I would probably not be interested
buying an add-on S-plus module unless the price were very inexpensive.
Most of the time I pass data back and forth between S-plus and GRASS
using shell scripts and S-Plus BATCH mode, with any necessary datafile
pre- or post-massage accomplished by UNIX text processing tools, i.e.
grep, sed, nawk, tr, etc.  These make data exchange simple, in most
instances.  S-plus BATCH mode command files can be customized
on-the-fly using shell script "here documents"-- the only thing to be
careful about is that you often need to explicitly wait for the S-plus
code to finish executing before continuing with the rest of the script,
because BATCH mode commands execute in the background.  The best way I
have found to deal with this is to create a flag file as the last
command in the Batch mode script, then force the rest of the script to
wait for it to appear, for example (in a Bourne shell script

# clean up any existing flag-file:
if [ -f s.done ]
then
	rm s.done
fi

# now build the S-plus command file:
cat > s.cmds <<- EOF
	# your S commands go here, then:
	cat ("Done\n", file="s.done")
EOF

# execute the S-plus commands:
Splus BATCH s.cmds s.out

# wait for S-plus to finish:
if [ ! -f s.done ]
then
	sleep 1
fi

If anyone else has a more elegant way of doing this, I would appreciate
hearing about it.  I've tried the UNIX "wait" command, but without
success.

Using shell scripts to integrate GRASS and S-plus makes it easy to
share data, customize file names and commands, and automate long or
repetitive analyses.  I've recently used this approach to perform
forest pest insect infestation risk assessments, endangered species
habitat suitability assessments, and forest management simulations at
regional scale.  It's also a great way to prototype GIS tools that you
hope to one day re-code entirely in C.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Michael Camann                  camann at dial.pick.uga.edu
Department of Entomology        camann at sparc.ecology.uga.edu
University of Georgia           (706) 542-2303 voice
Athens, GA 30602                (706) 542-2640 FAX

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



More information about the grass-user mailing list