If you find this document usefull, please consider ordering a printed hardcopy!
In the latest version 6.0the vector libraries underwent a complete reorganization. This was necessary because the GRASS version 5.4a strong focus on raster data and sites analysis. This course will focus on the new GRASS version 6.0functions. The changes to the vector format can be found in chapter 10.
To import vector data it is essential to take a multitude of different format and standards into consideration. Compared to raster formats the structure of vector data is more complex. This makes vector import more complicated. Table 8 lists the formats which are supported by GRASS GIS. Probably the most frequently used format is the ESRI SHAPE format.
Once the vector file is imported, it will be available in the native GRASS binary vector format. The geometries, topologies, and all attributes are stored in the internal GRASS database. A topology is created for each map during the import. The current topology status can be displayed via the command v.info. More vector related commands are described in chapter 10.
| GRASS | Import |
|---|---|
| Module command | Vector format |
| v.in.ogr | SHAPE file, UK.NTF, SDTS, TIGER, S57, MapInfo-File, |
| DGN, VRT, AVCBin, REC, Memory, GML, ODBC | |
| (see also: http://www.gdal.org/ogr/ogr_formats.html) | |
| v.in.ascii | GRASS ASCII |
| v.in.e00 | ArcInfo-E00-format |
| v.in.db | Create vectors from database with x|y[|z] coordinates |
Importing a SHAPE File
The module for importing SHAPE data to GRASS is called v.in.ogr. Note that the SHAPE format is not a topological format; there are no situation and/or neighbor relations between the individual objects. For example, border lines between two areas (polygones) are saved twice. This may lead to problems and therefore has to be corrected by GRASS during the import process.
The data for this exercise comes from the FRIDA project (17), which maintains a large quantity of detailed vector data of the city of Osnabrueck which are made available by Intevation GmbH (13).
v.in.ogr -o dsn=./frida-1.1-shp-joined/streets-joined.shp out=streets
12323 primitives registered 0 areas built 0 isles built Number of nodes : 8937 Number of primitives: 12323 Number of points : 0 Number of lines : 12323 Number of boundaries: 0 Number of centroids : 0 Number of areas : 0 Number of isles : 0
Within GRASS (under $GISDBASE/$LOCATION/$MAPSET) a subfolder named streets has been created in the directory vector during the import. In this directory the topology (topo), the header information (head), the vector geometries (coor), the history (hist), the spacial index (sidx), and the category index (cidx) as well as a link to the corresponding attribute data (dbln) are stored.
According to the default the attribute data has been stored within GRASS in the directory dbf as DBASE format - also during the import. If required, it is possible to have a look at the content of the newly imported attribute table (streets.dbf) with an appropriate editor. Under GNU/Linux this can be done with OpenOffice, Gnumeric or Koffice.
Other methods for importing vector data or generating vector data based on databases such as PostgreSQL or PostGIS can be found in chapter 10.
If the vector data contain their own projection information, a new location can be created during a GRASS session, which is based on this information. The necessary information of SHAPE data are saved in the file with the ending .prj. Creating a new location with the import of the data has the following syntax:
v.in.ogr dsn=./frida-1.1-shp-joined/streets-joined.shp \ out=streets location=osnabrueck
If you find this document usefull, please consider ordering a printed hardcopy!