Introduction to GRASS GIS Time Series Analysis of Remote Sensing Data

Micha Silver Remote Sensing Laboratory Ben Gurion University, Sde Boker Campus

11/06/2018

email: [email protected]

(Sde Boker - Remote Sensing Lab) 11/06/2018 1 / 22 Goals

Some background

Initial setup

Examples of batch processing

Define and analyze GRASS Spatial-Temporal Dataset

(Sde Boker - Remote Sensing Lab) 11/06/2018 2 / 22 Overview

Among the most experienced GIS in the world Actively developed, current stable version: 7.4.0 License: GPL About 350 modules - raster, vector, database, space-time Over 130 addons Topologically clean vector format 3D visualizations Fully script-able in bash or python GRASS Development Team, 2018. Geographic Resources Analysis Support System (GRASS) Software, Version 7.4. Open Source Geospatial Foundation. https://grass.osgeo.org

(Sde Boker - Remote Sensing Lab) 11/06/2018 3 / 22 Flood hazards Shortest distance Landscape changes LIDAR point clouds

Use cases

Flooding simulation

(Sde Boker - Remote Sensing Lab) 11/06/2018 4 / 22 Shortest distance Landscape changes LIDAR point clouds

Use cases

Flooding simulation Flood hazards

(Sde Boker - Remote Sensing Lab) 11/06/2018 4 / 22 Landscape changes LIDAR point clouds

Use cases

Flooding simulation Flood hazards Shortest distance

(Sde Boker - Remote Sensing Lab) 11/06/2018 4 / 22 LIDAR point clouds

Use cases

Flooding simulation Flood hazards Shortest distance Landscape changes

(Sde Boker - Remote Sensing Lab) 11/06/2018 4 / 22 Use cases

Flooding simulation Flood hazards Shortest distance Landscape changes LIDAR point clouds

(Sde Boker - Remote Sensing Lab) 11/06/2018 4 / 22 Interaction with Open Source GIS Ecosystem

(Sde Boker - Remote Sensing Lab) 11/06/2018 5 / 22 Interaction with Open Source GIS Ecosystem

(Sde Boker - Remote Sensing Lab) 11/06/2018 5 / 22 Interaction with Open Source GIS Ecosystem

(Sde Boker - Remote Sensing Lab) 11/06/2018 5 / 22 Online Documentation

Tutorial: http://www.training.gismentors.eu/grass-gis-workshop-jena-2018/ units/01.html Wiki: https://grasswiki.osgeo.org/wiki/From_GRASS_GIS_novice_to_power_ user_(workshop_at_FOSS4G_Boston_2017) The GRASS book: https://grassbook.org/ User’s maillist: http://lists.osgeo.org/mailman/listinfo/grass-user NCSU Lab: http: //ncsu-geoforall-lab.github.io/geospatial-modeling-course/grass/ Spatial-Temporal workshop: http://ncsu-geoforall-lab.github.io/grass-temporal-workshop/

(Sde Boker - Remote Sensing Lab) 11/06/2018 6 / 22 Getting help

Built-in manuals and help

(Sde Boker - Remote Sensing Lab) 11/06/2018 7 / 22 Getting help

Built-in manuals and help

(Sde Boker - Remote Sensing Lab) 11/06/2018 7 / 22 Two take-home messages: 1 Location = Coordinate System 2 Set GRASS region

GRASS - Initial setup

GRASS Database

I Location defined by coordinate reference system I Mapset contains data for a project Always check and set computational region

(Sde Boker - Remote Sensing Lab) 11/06/2018 8 / 22 Two take-home messages: 1 Location = Coordinate System 2 Set GRASS region

GRASS - Initial setup

GRASS Database I Location defined by coordinate reference system I Mapset contains data for a project Always check and set computational region

(Sde Boker - Remote Sensing Lab) 11/06/2018 8 / 22 GRASS - Initial setup

GRASS Database

I Location defined by coordinate reference system I Mapset contains data for a project Always check and set computational region

Two take-home messages: 1 Location = Coordinate System 2 Set GRASS region

(Sde Boker - Remote Sensing Lab) 11/06/2018 8 / 22 GRASS - Initial setup

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

Find EPSG codes here: http://epsg.io/

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

Always set the computational region

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

Always set the computational region

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

Always set the computational region

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 GRASS - Initial setup

(Sde Boker - Remote Sensing Lab) 11/06/2018 9 / 22 Batch Processing in GRASS

(Sde Boker - Remote Sensing Lab) 11/06/2018 10 / 22 Language choices: Windows command prompt cmd.exe bash shell script (also on MacOS) python (any OS)

Batch Processing

Time series analysis requires processing large batches of input

(Sde Boker - Remote Sensing Lab) 11/06/2018 11 / 22 python (any OS)

Batch Processing

Language choices: Windows command prompt cmd.exe Linux bash shell script (also on MacOS)

(Sde Boker - Remote Sensing Lab) 11/06/2018 11 / 22 Batch Processing

Language choices: Windows command prompt cmd.exe Linux bash shell script (also on MacOS)

python (any OS)

(Sde Boker - Remote Sensing Lab) 11/06/2018 11 / 22 Batch Processing

Language choices: Windows command prompt cmd.exe Linux bash shell script (also on MacOS)

python (any OS)

I Python scripting in GRASS session: import grass . script as gscript

(Sde Boker - Remote Sensing Lab) 11/06/2018 11 / 22 GRASS - Batch import

GRASS command names: general commands: g.∗ raster commands: r .∗ vector commands v.∗ temporal commands t .∗ Start GRASS pointing to the LOCATION/MAPSET that we created: # The location/mapset was already created GRASS DIR=”$ {BASE DIR}/grassdata/UTM31N/camargue” cd ${TARGET DIR} # Start grass grass $GRASS DIR

# All following commands are entered atGRASS terminal # ImportNDVI rasters f o r f i n 20∗. t i f ; do r=‘basename $f .tif ‘ r . i n . input=$f output=”ndvi $ { r }” band=1 done

(Sde Boker - Remote Sensing Lab) 11/06/2018 12 / 22 GRASS - Set Computational Region

# Geta list of allGRASS rasters RAST LIST=‘g. list rast separator=comma pattern=ndvi ∗ ‘ # Set computational region g . r e g i o n −p r a s t=${RAST LIST} # Apply color ramp to the whole list r. colors map=${RAST LIST} o l o r=n d v i

(Sde Boker - Remote Sensing Lab) 11/06/2018 13 / 22 STRDS in GRASS

Spatial-Temporal Raster Datasets

(Sde Boker - Remote Sensing Lab) 11/06/2018 14 / 22 GRASS - Seasonal Difference in NDVI

Use map calculator to get diff between NDVI from two dates

# Compare Winter/Summer difference r . mapcalc”season d i f f= 1.0 ∗ (ndvi 20170702 − ndvi 20180123)” r.colors season diff color=${CODE DIR}/ d i f f r a m p . t x t Note: multiply by 1.0 to force REAL number, otherwise an INTEGER raster is created

(Sde Boker - Remote Sensing Lab) 11/06/2018 15 / 22 GRASS - Seasonal Difference in NDVI

(Sde Boker - Remote Sensing Lab) 11/06/2018 15 / 22 GRASS - Spatial Temporal Raster DataSet

Create a new, empty Spatial-Temporal Raster Dataset ( strds )

# Create and populate space −t i m e raster dataset t.create output=camargue ndvi type=s t r d s temporaltype=absolute title=”camargue NDVI” \ description=”camargue NDVI time series” and populate with all NDVI rasters, using bash date manipulation to set start and end times f o r r i n ‘g.list rast pattern=ndvi ∗ ‘; do y=${ r : 5 : 4 } m=${ r : 9 : 2 } d=${ r : 1 1 : 2 } s d t=$y−$m−$d e d t =‘ date −d”$s d t+1 days”+”%Y −%m−%d”‘ t. register input=camargue ndvi maps=$r \ s t a r t=$ s d t end=$ e d t −−o v e r w r i t e done

(Sde Boker - Remote Sensing Lab) 11/06/2018 16 / 22 View the Timeline g.gui.timeline strds=camargue ndvi g.gui.animation strds=camargue ndvi

GRASS - Check STRDS

Set color ramp, and check info t.rast.colors camargue ndvi color=ndvi t.info camargue ndvi t.rast.list camargue ndvi colu=id ,start t i m e , end time

(Sde Boker - Remote Sensing Lab) 11/06/2018 17 / 22 GRASS - Check STRDS

Set color ramp, and check info t.rast.colors camargue ndvi color=ndvi t.info camargue ndvi t.rast.list camargue ndvi colu=id ,start t i m e , end time View the Timeline g.gui.timeline strds=camargue ndvi g.gui.animation strds=camargue ndvi

(Sde Boker - Remote Sensing Lab) 11/06/2018 17 / 22 Add Animation Add STRDS to animation Choose the STRDS

GRASS - STRDS Animation

Show STRDS as animation

(Sde Boker - Remote Sensing Lab) 11/06/2018 18 / 22 Show STRDS as animation

Add STRDS to animation Choose the STRDS

GRASS - STRDS Animation

Add Animation

(Sde Boker - Remote Sensing Lab) 11/06/2018 18 / 22 Show STRDS as animation Add Animation

Choose the STRDS

GRASS - STRDS Animation

Add STRDS to animation

(Sde Boker - Remote Sensing Lab) 11/06/2018 18 / 22 Show STRDS as animation Add STRDS to animation Add Animation

GRASS - STRDS Animation

Choose the STRDS

(Sde Boker - Remote Sensing Lab) 11/06/2018 18 / 22 GRASS - Animation Result

(Sde Boker - Remote Sensing Lab) 11/06/2018 19 / 22 GRASS - STRDS Aggregation

Module: t.rast.series

#t.rast.series example t.rast. series input=camargue ndvi@camargue method=slope \ where=”start t i m e >’2017−09−01 00:00’ and \ s t a r t t i m e <’2017−12−31” output=camargue n d v i s l o p e f a l l

(Sde Boker - Remote Sensing Lab) 11/06/2018 20 / 22 GRASS - STRDS Aggregation

(Sde Boker - Remote Sensing Lab) 11/06/2018 20 / 22 GRASS Interpolate Missing Time slots

Linear interpolation between dates Module: t.rast.gapfill

(Sde Boker - Remote Sensing Lab) 11/06/2018 21 / 22 GRASS Interpolate Missing Time slots

Linear interpolation between dates Module: t.rast.gapfill

(Sde Boker - Remote Sensing Lab) 11/06/2018 21 / 22 GRASS Interpolate Missing Time slots

List of maps in STRDS, including interpolated

(Sde Boker - Remote Sensing Lab) 11/06/2018 21 / 22 GRASS Interpolate Missing Time slots

List of maps in STRDS, including interpolated

(Sde Boker - Remote Sensing Lab) 11/06/2018 21 / 22 Thanks

Thanks for your attention

(Sde Boker - Remote Sensing Lab) 11/06/2018 22 / 22