Unit 03 - Data Management

Data can be imported simply from toolbar by tools dedicated for raster or vector GIS data formats grass-layer-import. 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.

../_images/import-raster-toolbar.png

Fig. 11 Import raster data from the main toolbar.

Note

Dialog for importing raster data is also accessible from menu File ‣ Import raster data ‣ Simplified raster import with reprojection or from command line by r.import module.

Import 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).

../_images/import-raster-dialog.svg

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).

../_images/override-projection-check.svg

Fig. 13 Override projection check to force import.

After successful operation imported data layer should be automatically displayed in Map Window.

../_images/sentinel.png

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.

../_images/import-vector-toolbar.png

Fig. 15 Import vector data from the main toolbar.

Note

Dialog for importing vector data is also accessible from menu File ‣ Import vector data ‣ Simplified vector import with reprojection or from command line by v.import module.

../_images/import-vector-dialog.svg

Fig. 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.

../_images/import-vector-reproject.png

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.

../_images/fylke.png

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.

../_images/vector-metadata-features.png

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.

../_images/grass7-topo.png

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.

A new mapset can be created by g.mapset or from menu Settings ‣ GRASS working environment ‣ Create new mapset.

../_images/create-mapset.png

Fig. 21 Create a new mapset.

Querying data

Imported raster or vector data layers can be iteractively queried by grass-info from Map Window toolbar.

../_images/query-map-window.png

Fig. 22 Query interactively Norway administrative regions.

Vector data layers (GRASS vector maps) can be queried also by attribute filters using Attribute Table Manager grass-table.

../_images/show-attrb-data-menu.png

Fig. 23 Open Attribute Table Manager from layer menu.

Vector features can be queried by simple SQL queries by WHERE statement.

../_images/simple-query.png

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.

../_images/advanced-query.svg

Fig. 25 Open SQL Builder.

../_images/sql-builder.png

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 Extract selected features.

../_images/extract-menu.png

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 grass-zoom-extent as shown on Fig. 28.

../_images/oslo-region.svg

Fig. 28 Oslo region and Sentinel band displayed in Map Window.

Let’s change symbology of Oslo polygon vector map.

../_images/layer-props.png

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.

../_images/d-vect.png

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

../_images/oslo-sentinel.png

Fig. 31 Example of vizualization of map layers composition.