If you find this document usefull, please consider ordering a printed hardcopy!


Subsections


2 Management of vector geometries

The management of vector geometries has completely been changed in GRASS version 6.0. Geometries are stored in the new GRASS-specific vector format ("native format") as standard setting. This basic setting can thus be modified without any problem, so that at present PostGIS, SHAPEs and other OGR supported formats can be saved and processed.

Figure: Representation of the GRASS 6.0architecture
\includegraphics[clip=true, width=\textwidth]{finalpix/grass57vectorarch.eps}

For a better comprehension, for instance, the use of the different currently supported vector formats will be introduced. The Free Geodata of the FRIDA project are used for this purpose (see (17)).

1 Working with OGR formats

Due to the new implementation of the OGR support, the support for a quantity of vector formats is now available. A detailed list of all formats supported by OGR can be found in chapter 8 on page [*] as well as on the internet page of the OGR Software Suite (15).

ESRI SHAPE files can be used directly in GRASS. For this purpose the new integrated module v.external is used, which makes the necessary connection between GRASS and the OGR source. During this process a GRASS-internal pseudo-topology is automatically created for non-topological data, so that network analyses are also possible with this data. Note that when using v.external GRASS has read-only access to the data, which is slower than if the data are imported:

# Create a SHAPE link
v.external dsn=./gdf/shapes/layer=frida_stras out=frida_stras_ext

# Display SHAPE
d.vect frida_stras_ext

# Query SHAPE
d.what.vect frida_stras_ext

In order to change the data, the OGR data source must be imported into the native GRASS format:

g.copy vect=frida_stras_ext,frida_stras_int
v.digit frida_stras_int

This can be done by copying the already mounted map with the module g.copy or by importing the dataset with the module v.in.ogr (see chapter 5.2).

Similarly, all formats supported by OGR can directly accessed and/or imported into GRASS.

Also PostGIS can be used to interface with the UMN mapserver. So it is easy to present GRASS-results through PostGIS and UMN mapserver on the internet.


2 Creating geometries out of DBMS

If data with coordinate pairs (X/Y) and attributes are available as DBF, CSV, MS-Excel, PostgreSQL and so on, it is possible to generate a map in GRASS. A simple table 'stations' saved in PostgreSQL in the database 'mydb' is used for this example:

v.in.db driver=pg database="host=localhost,dbname=mydb,user=postgres" \
        table=stations x=east y=north z=quota key=ID output=stations

If no ID column is available in dBase tables, you need to create an incremental ID-number using an external programs e.g. Openoffice.org.


3 Creating geometries using XY and/or XYZ textfile

If XY or XYZ coordinates are saved as a simple ASCII text 'coords.txt', 2D or 3D maps can be created as follows:

a) Example for a 2D map:

  1664619|5103481
  1664473|5095782
  1664273|5101919
  1663427|5105234
  1663709|5102614

# Import to GRASS:
cat coords.txt | v.in.ascii out=my2dmap

# Supplementation of missing category values for attaching 
# attributes later
v.category in=my2dmap out=my2dmap_final op=add
v.category my2dmap_final op=report

b) Example for a 3D map:

  1664619|5103481|445.1
  1664473|5095782|534.2
  1664273|5101919|532.9
  1663427|5105234|454.4
  1663709|5102614|525.7

Import to GRASS:
cat coords.txt | v.in.ascii -z out=my3dmap

# Supplementation of missing category values for attaching
# attributes later
v.category in=my3dmap out=my3dmap_final op=add
v.category my3dmap_final op=report

An available attribute table can be assigned by the module v.db.connect.


If you find this document usefull, please consider ordering a printed hardcopy!


© 2005, GDF Hannover bR - Solutions for spatial data analysis and remote sensing
Last modified: 29-08-2005