Unit 03 - Data Management¶
Data can be imported simply from toolbar by tools dedicated for
raster or vector GIS data formats . Basic
knowledge of commonly used GIS file formats is required.
Note
GRASS terminology differs from commonly used GIS packages. To avoid confusion let’s focus on the most important terms. Commonly used term “a layer” is called in GRASS “a map”. GRASS layer is subset of features with one “map”. So “GRASS raster map” can be treated as “a raster layer” in other GIS packages.
Import GIS data¶
Raster data¶
Let’s start with data file used for creating our project location in
Unit 02 - First steps. L2A_T32VNM_20170705T105031_B04_10m.jp2
is a
JPEG2000 file, which is nowadays commonly used GIS
raster format for imagery data.

Fig. 11 Import raster data from the main toolbar.
Note
Dialog for importing raster data is also accessible from menu r.import module.
or from command line byImport dialog allows importing single vector file (File) or multiple files from directory (Directory). In our case single file is planned to be imported, we keep default data source (File).
Fig. 12 Dialog for importing raster file(s).
Important
If a spatial reference system (SRS) of raster file differs from GRASS location (Project match) input raster data are automatically reprojected into SRS of current GRASS location. Note that GRASS simply does not support on the fly transformation from several reasons.
Note
In some cases SRS of imported file can be missing or invalid. GRASS reports this issue as In case of no significant differences in the projection definitions, use the -o flag to ignore them and use current location definition. Consider generating a new location from the input dataset using the ‘location’ parameter.
GRASS allows importing such file by overriding project check (if you are really sure that SRS of input file is the same as GRASS location).
Fig. 13 Override projection check to force import.
After successful operation imported data layer should be automatically displayed in Map Window.

Fig. 14 Imported Sentinel band displayed in Map Window.
Note
GRASS imports/links RGB image as separate bands. Color composition can be displayed using d.rgb. By r.composite it is possible to create color composite as a new raster map.
Vector data¶
Norway administrative regions are stored in
~/geodata/counties/Basisdata_0000_Norge_25833_Fylker_GML.gml
GML file, which is a commonly used GIS exchange vector
format.

Fig. 15 Import vector data from the main toolbar.
Note
Dialog for importing vector data is also accessible from menu v.import module.
or from command line byFig. 16 Dialog for importing vector file(s). Input file
Basisdata_0000_Norge_25833_Fylker_GML.gml
contains several
layers, we choose “Fylke” (administrative regions) to import.
In this case appearently SRS of input data layer and current GRASS location differs (see Project match: No on Fig. 16), reprojection of input data will be requested.

Fig. 17 Reprojection needs to be confirmed by a user by Import & reproject.
After successful operation imported data layer should be automatically displayed in map window.

Fig. 18 Imported Norway administrative regions.
Vector topology¶
Let’s take a closer look at vector metadata of imported administrative regions. Instead of “polygons” there are “areas” and other kind of primitites (points, lines, boundaries, centroids, isles), see Fig. 19.

Fig. 19 Vector metadata of imported file.
GRASS GIS is a topological GIS. Importing vector data into GRASS also means converting features from simple feature model (points, linestrings, polygons, …) into GRASS topological model.

Fig. 20 GRASS topological model with primitives (nodes, lines, boundaries, centroids, areas, and isles).
Topological errors are checked and repaired by GRASS GIS when importing data, be awere of snap option of v.import module. Topological errors which is not possible repair automatically without user specification can fixed using v.clean module.
Work organization¶
GRASS GIS allows organizing work within one project (GRASS location) by creating different mapsets, see Unit 02. In the next units various analysis will be performed in “Oslo” region. Let’s create a new mapset called “oslo” for upcoming work.
Querying data¶
Imported raster or vector data layers can be iteractively queried by
from Map Window toolbar.

Fig. 22 Query interactively Norway administrative regions.
Vector data layers (GRASS vector maps) can be queried also by
attribute filters using Attribute Table Manager .

Fig. 23 Open Attribute Table Manager from layer menu.
Vector features can be queried by simple SQL queries by WHERE statement.

Fig. 24 Simple attribute querying.
Tip
GRASS offers also interactive tool for attribute querying similarly to other GIS packages. The tool accessible from Builder tab as SQL Builder.
Fig. 25 Open SQL Builder.

Fig. 26 SQL Builder in action.
Selected vector objects (commonly refered as “features” in GIS terminology) can be saved into new layer (GRASS vector map) from menu by
.
Fig. 27 Extract selected features into a new vector map.
Created vector map is automatically added into Layer Tree. Switch
visibility of map layers by checkboxes and zoom to currently selected
map (oslo) by as shown on Fig. 28.
Fig. 28 Oslo region and Sentinel band displayed in Map Window.
Let’s change symbology of Oslo polygon vector map.

Fig. 29 Open map layer properties from menu. Properties dialog can be open also simply by double-clicking on map layer item.
Feature outline and fill color can be changed in Colors tab.

Fig. 30 Change polygon outline color. Fill color set to transparent. Line width can be changed in Lines tab.

Fig. 31 Example of vizualization of map layers composition.