# 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”. While GRASS layer is a subset of features within one “map”. So “GRASS raster map” can be treated as “a raster layer” in other GIS packages.

## Data import¶

Data used in this unit is located in geodata/sentinel/sample directory of a sample dataset.

### Raster data¶

Let’s start with L2A_T32UPB_20170706T102021_B04_10m.jp2 file. Sentinel’s 4th band is a JPEG2000 file, which is nowadays commonly used GIS raster format for imagery data.

Fig. 14 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 raster file (File) or multiple files from directory (Directory). In our case single file is planned to be imported.

Fig. 15 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 a 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).

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

Fig. 16 Imported Sentinel band displayed in Map Window. Default grey color table is not perfect as you can see, color interpretation will enhanced in Unit 04.

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.

Basic raster metadata can be printed by r.info or from Layer Manager.

Fig. 17 Display raster map metadata from Layer Manager.

Fig. 18 Raster metadata of imported file.

Raster maps are represented by regular grid. Three different data types are supported:

• CELL (integer)
• FCELL (float)
• DCELL (double)

### Vector data¶

Let’s import vector cloud mask data layer located in geodata/sentinel/sample directory. Cloud mask is stored in MSK_CLOUDS_B00.gml GML file, which is a commonly used GIS exchange vector format.

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

Fig. 20 Dialog for importing vector file(s).

After successful operation imported data layer should be automatically displayed in map window.

Fig. 21 Map composition of Sentinel band and cloud mask features.

Vector metadata can be printed similarly to raster maps from Layer Manager by Metadata or using v.info module from console.

## 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 primitives (points, lines, boundaries, centroids, isles), see Fig. 22.

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

To avoid data duplication GRASS also allows linking raster data using r.external (Link external raster data) and vector data by v.external (Link external vector data).

Fig. 24 Link raster or vector data from Layer Manager.

Linking data is mainly recommended when working with raster data such large datasets of imagery data. GRASS can handle linked raster data similarly as native raster maps. Both from point of stability and accessibility.

GUI dialog for data linking is the same as for import, see Fig. 15. Let’s create a link to 8th Sentinel band JP2 file geodata/sentinel/sample/L2A_T32UPB_20170706T102021_B08_10m.jp2.

From metadata it is clear than 4th band was imported into native GRASS format, while 8th band was linked directly from original JPEG2000 format.

Fig. 25 Linked raster file in external format by r.external.

Fig. 26 Imported raster file in native GRASS format by r.in.gdal (or r.import).