Unit 03 - Data Management

Data import

Data used in this unit is located in sentinel/sample directory of a sample dataset (download 7z-archive).

Raster data

Raster data is possible to import from the menu File ‣ Import raster data ‣ Common import formats, from a main toolbar, or from command line by r.import module.

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

Fig. 16 Import raster data from the main toolbar.

Import dialog allows importing single raster file (File) or multiple files from directory (Directory). If spatial reference system of raster file differs from GRASS location (Project match) the raster data are automatically reprojected (please forget about on-the-fly reprojection).

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

Fig. 17 Dialog for importing raster file(s).

../_images/display-band4.png

Fig. 18 Imported raster file (Sentinel 4th band) is added into layer tree and displayed in map window. Default grey color table is not perfect as you can see, we will enhance color interpretation in Unit 04.

GRASS imports raster bands as separate raster maps. Raster maps are represented by regular grid. Three different data types are supported:

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

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

../_images/raster-metadata.png

Fig. 19 Display raster map metadata from Layer Manager.

../_images/raster-metadata-cell.png

Fig. 20 Raster metadata of imported file.

Vector data

Dialog for importing vector data is accessible from menu File ‣ Import vector data ‣ Common import formats, from a main toolbar, or from command line by v.import module.

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

Fig. 21 Import vector data from the main toolbar.

Procedure of importing vector files is similar to raster files.

../_images/import-vector-dialog.png

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

Note

In some cases SRS of imported file can be missing or invalid. This is our case. 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. 23 Override projection check to force import.

../_images/display-band4-clouds.png

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

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

Vector topology

Let’s take a closer look at vector metadata. There are no “polygons” but “areas” and other kind of priminites (points, lines, boundaries, centroids, isles).

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

Fig. 25 Vector metadata of imported file.

GRASS is a topological GIS. Importing vector data into GRASS also means converting features from simple feature model (points, linestrings, polygons, …) into GRASS topological model, see figure bellow.

../_images/grass7-topo.png

Fig. 26 GRASS topological model with primitives like nodes, lines, boundaries, centroids, areas, and isles.

During this process also topological errors are checked and repaired, be awere of snap option of v.import module.

Some topological errors is not possible to repair automatically without user specification, in this case the user can fix remaining errors using v.clean module.

Linking external formats

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

../_images/link-data-menu.png

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

Linking 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. 17. Let’s create a link to 8th Sentinel band JP2 file.

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

../_images/raster-linked.png

Fig. 28 Linked raster file in external GRASS format by r.external.

../_images/raster-imported.png

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