[GRASS-dev] online GRASS GIS DB

Glynn Clements glynn at gclements.plus.com
Thu Aug 14 01:28:58 EDT 2008


chris carleton wrote:

> I appreciate the time anyone takes to respond to this one. I want to
> create an online GIS database from which users can access,
> download, analyze, and submit (after review) spatial data. I would
> like to use GRASS and a Unix based server for all of this. Ideally,
> there would just be a webpage with a username password requirement
> rather than distributing an anonymous account to interested parties
> (so that folks really only have access to the GIS database and nothing
> else on the server - also much more user friendly for non-unix users).
> I've never created a database that is accessible from a website (and
> never a relational geo-spatial database). Am I going to be able to use
> GRASS in this way and can anyone provide me with some references to
> get started or perhaps a currently operational example that is using
> GRASS? Essentially, what do I need to know and how do I get GRASS to
> work with a database online - just a readling list or some websites to
> get me started would be apprecitated as my googling hasn't been
> particularly fruitfull thus far. Thanks again,

You can certianly use GRASS in this way, but I can't point you to any
particular information on doing so.

Almost all of GRASS' functionality is provided by around 300
non-interactive, command-line programs. Once certain files and
environment variables have been set up, these programs can be used
from within a CGI script.

You can determine the necessary setup by reverse-engineering the
etc/Init.sh script in any GRASS installation, but the main points are:

$GISBASE needs to expand to the path of the directory where GRASS is
installed, e.g. "/usr/local/grass-7.0".

$PATH needs to include $GISBASE/bin and $GISBASE/scripts, while
$LD_LIBRARY_PATH (for Linux) needs to include $GISBASE/lib.

$GISRC needs to expand to the path to a file containing settings for
at least GISDBASE, LOCATION_NAME and MAPSET, e.g.:

	GISDBASE: /opt/grass-data
	LOCATION_NAME: spearfish57
	MAPSET: glynn

This file should typically be created when the user logs in. The
filename can be based upon the username (if you are using HTTP
authentication) or stored in a cookie. Each subsequent execution of a
CGI script will need to set GISRC to refer to that file before
invoking any GRASS commands.

$GIS_LOCK is supposed to contain the PID of the session shell, but
that won't be meaningful for a CGI program. AFAICT, the only real
requirement is that the variable is actually set, and this only
affects g.mapset.

$GRASS_PAGER is the program used to paginate the output of some
programs. For interactive use, it's normally set to "more" or "less",
but should probably be "cat" for CGI use.

$GRASS_MESSAGE_FORMAT should be set to "gui" or "silent" for
non-interactive use. The default format uses some terminal control
code (backspace, carriage-return), which isn't appropriate for CGI.

There are a handful of other environment variables that may be used by
specific modules, but those mentioned above are the main ones.

To use the d.* commands, which produce graphical output, you may also
need:

	GRASS_RENDER_IMMEDIATE=TRUE

This causes d.* commands to generate image files directly, rather than
communicating with a separate driver process.

	GRASS_TRUECOLOR=TRUE

Generate 24-bpp images (8-bpp is the default).

	GRASS_TRANSPARENT=TRUE

Use a transparent background for PNG images.

	GRASS_WIDTH=640
	GRASS_HEIGHT=480

Specify the image dimensions.

The main issue is whether to use 6.4.x or 7.x. 7.x is in active
development (i.e. "unstable"), but some of that development will be
useful from the perspective of writing a web application. In
particular, one of the main development tasks is replacing
functionality which relies upon the user interacting via a terminal.

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


More information about the grass-dev mailing list