[GRASS5] Re: grass5.1-vector-reading

Radim Blazek blazek at itc.it
Wed Nov 27 05:09:14 EST 2002

On Tuesday 26 November 2002 08:10 pm, Nico Hardebol wrote:
> Dear Grass developpers,
> With a small group of geological and geophysical master students (Utrecht
> University - Geophysica & VU - Amsterdam/ Tectonic depart. under prof. S.
> Cloetingh) we are at the moment getting familiar with grass and try to
> implement a geotectonic rotation script placed between SQL - requests sent
> by grass and a spatial database PostgreSQL - to allow plate tectonic
> reconstructions within grass.
> We already changed and programmed some lsmall euler-rotation scripts which
> rotate tectonic plate shape -polygons. Visualization must be done by GIS -
> and to us grass is the best solution - due to the great possibilities of
> the gras5.0 release and its future perspectives

Can you explain what the script does with vectors? Transforms coordinates?
Must be done dynamicaly? What is the variable the transformation depends on? 
Are there created new objects? Works on geometry only or on attributs?

> We have some experience with grass 5.0.0 - we also bought your new book on
> open GIS. Your internet site and your article on the new grass5.1
> architecture suggests a fully integrated grass with DBMS - PostgreSQL. In
> respect to our approach of writing a transformation script this new version
> grass5.1 is inportant and the following questions are relevant to us:
> 1) how is the SQL requesting organized within grass5.1
> 2) how is the data delivered from the database back to grass5.1 for
> visualization.
To get some flexibility, geometry and atributes are handled by separate 
a) Attributes are read/written through DBMI lib in usual way
similar to other SQL clients, example:
    driver = db_start_driver(Fi->driver);
    db_set_handle (&handle, Fi->database, NULL);
    db_open_database(driver, &handle);
    sprintf(buf,"SELECT %s FROM %s WHERE %s\n", col, tab, where);
    db_append_string ( &stmt, buf);
    db_open_select_cursor(driver, &stmt, &cursor, DB_SEQUENTIAL);
    table = db_get_cursor_table (&cursor);
    column = db_get_table_column(table, 0); /* first column */
    value  = db_get_column_value(column);
    type = db_get_column_sqltype(column);
    type = db_sqltype_to_Ctype(type);
    while(1) {
       db_fetch (&cursor, DB_NEXT, &more);
       if (!more) break;
       val = db_get_value_int(value);
b) Geometry is read directly from PostGis/Postgress and this is completely
hidden in vector library and can be accessed by Vect_* functions only.

> 3) Where are we going to put our script within the data-stream.

Why must be in the stream? Cannot work as usual Grass module?

> To get familiar with grass5.1 and its linking with postgreSQL I downloaded
> and installed the grass5.1 pre-compiled binaries.
> Grass5.1 seems to be installed pretty well. Grass5.1 and also the new d.m
> starts well (nice display manager). Raster data can be easily plotted but
> the vector data (for us the most interesting) offers problems.  Pressing
> the Vector Name button the sellection window pops up, but no datsets can be
> sellected.  Is this due to the fact that most modeles from Grass5.0 are
> missing and modules to load vector data are absent in the
> grass5.1 libraries?

Vector format is changed in 51, so you must first convert vectors from 
5.0 to 5.1 by v.convert. The best way to start with g51 is demo mapset
unpack, start grass, go to mapset and run 'tour'

> from the install notes
> " ....Note that most modules from GRASS 5.0 are missing. However, they
> can be easily linked into the ./dist.$ARCH structure if needed.
> Or, new directories with new Makefiles must be added and the
> directory defined in ./tools/link.conf...."

Only that modules from g50 which do not work with vectors or X driver may be 
run in grass51. Before you run g50 module you must set some variables
(paths to g50), example:
export PATH=/amd/ssi0/ssi/blazek/grass/dist.i686-pc-linux-gnu/bin:$PATH;
export GISBASE=/amd/ssi0/ssi/blazek/grass/dist.i686-pc-linux-gnu;

> How can we load vectore data in grass5.1 via d.m - do we have to link
> grass5.0 modules? How?

Via d.m no, it is display manager, use v.convert.


More information about the grass-dev mailing list