lund 2015 - qgis workshop

36
Workshop – Lund 2015 1 Landscape ecology analysis with QGIS Workshop at Lund University (2015) by Martin Jung

Upload: martin-jung

Post on 16-Jul-2015

86 views

Category:

Environment


4 download

TRANSCRIPT

Page 1: Lund 2015 - QGIS workshop

Workshop – Lund 2015 1

Landscape ecology analysis with QGISWorkshop at Lund University (2015) by Martin Jung

Page 2: Lund 2015 - QGIS workshop

Workshop – Lund 2015 2

About me

● BSc thesis about plant-pollinator networks in Białowieza● MSc thesis about broad-scale biodiversity modelling● Starting a PhD in september on Global biodiversity impacts of land-use

dynamics

● Using QGISQGIS since many years, two plugins (LecoS, QSDM)Twitter: @Martin_EcologyBlog: http://conservationecology.wordpress.com/

Page 3: Lund 2015 - QGIS workshop

Workshop – Lund 2015 3

Roadplan for today

1 Working with GIS formats and attributes in QGIS

2 Projections

3 Introduction to Georeferencing with QGIS

… Short break somewhere here ...

4 Landscape Analysis with QGIS (LecoS)

5 Questions and problems (...Open end...)

Page 4: Lund 2015 - QGIS workshop

Workshop – Lund 2015 4

Now install (if you haven't already)

● Make some room on your computer (at least 1 GB !)● Install the current Stable Version ( QGIS 2.8 ) on your computer (see

provided folder) for Windows● MAC-Users: Download QGIS and install python libraries● (http://www.kyngchaos.com/software/python )

Important!– Make sure the libraries python-scipy, python-numpy, python-pil and python-

matplotlib are checked

Page 5: Lund 2015 - QGIS workshop

Workshop – Lund 2015 5

● Select “Advanced Install”● “Install from local Folder”● Mark everything

– Qgis

– Python-numpy

– Python-scipy

– ...

How to install (WIN)

Install from local folder

Page 6: Lund 2015 - QGIS workshop

Workshop – Lund 2015 6

GIS dataformats

Source: maprabu.blogspot.com

Format: *.shp, *.csv, *.gpx, *.kml, ...

Format: *.tif, *.vrt, *.hdr, *.asc, ...

Page 7: Lund 2015 - QGIS workshop

Workshop – Lund 2015 7

Raster vs vector

● Vector– Advantage: Accuracy, more visually pleasing

– Disadvantage: Space-inefficient. Every vertex needs to be stored. Algorithms computational intensive.

● Raster– Advantage: Geogr. Position associated with data, easier for analysis

– Disadvantage: Resolution dependent on cellsize. Often not nice-looking

Page 8: Lund 2015 - QGIS workshop

Workshop – Lund 2015 8

Other data sources

● Google, Bing, Openstreetmaps, ... ( OpenLayers plugin)● WMS server, for instance the EEA WMS services

– http://discomap.eea.europa.eu/home.html

– Can be loaded into QGIS as WMS layer

Those files can be visualized, but not edited (see WFS) !!! You can make a screenshot though and georeference this, but check the publishers license!

Page 9: Lund 2015 - QGIS workshop

Workshop – Lund 2015 9

A note on proprietary formats

● Long-term ArcGIS users are often confronted with .lyr files– Proprietary format by ESRI. Container that stores data and viz

● (Open-source alternative in QGIS ← .qlr )

● TMK: Not convertible without having a ESRI license!– Arc2Earth extension for ArcMap lets you save .lyr to .sld

Page 10: Lund 2015 - QGIS workshop

Workshop – Lund 2015 10

What are Map projections

● Map projections to represent a 3-dimensional structure on a 2d planar plane

● Many formats and types– Spherical, azimuthal, equidistant, equal area, …

– Most commonly used: ● WGS84 (lon,lat ← In degree)● WGS84 Google Pseudo-Mercator (in meter, but inaccurate in tropics!!! )● WGS84 UTM (in meter, subdivided in lon-lat grids)

http://epsg.io/ ← Lookup projections

Page 11: Lund 2015 - QGIS workshop

Workshop – Lund 2015 11

Now hands on in QGIS

Page 12: Lund 2015 - QGIS workshop

Workshop – Lund 2015 12

Geo-referencing with QGIS

● GR is the process of associating data with spatial coordinates

● In QGIS using the excellent gdal-referencer

● What we need:– A non-spatial file– A reference projection– Reference points or ROI

Harsjön

Page 13: Lund 2015 - QGIS workshop

Workshop – Lund 2015 13

(1) Get the geocode plugin (or use the bar) to jump to 59.55275,18.33490 long-lat

(2) Load Google layers or any other WMS service

(3) Make sure the gdal-georeferencer is available (Raster menu)

(4) Add the Harsjön.tif file to the referencer and add around 5-6 GCP points – Choose linear interpolation

(5) Now you have the rasterized the map and create a new vector point layer with the study-locations

Page 14: Lund 2015 - QGIS workshop

Workshop – Lund 2015 14

Visualizing Gradients

● Add the pH-0915_3.csv to QGIS via “Add-delimited-Text-layer”

● Specify RT90 2.5 gon V as projection (assumed)

● Color the points with the Ph attribute

● Subset to Skane (Select – Save Selection). Computational intensive!!!

● Use the Heatmap plugin (Ph as weight) or GRASS-modules in Processing (v.surf.*)

Vector Raster

Page 15: Lund 2015 - QGIS workshop

Workshop – Lund 2015 15

Use the new Heatmap renderer (QGIS 2.8)

Page 16: Lund 2015 - QGIS workshop

Workshop – Lund 2015 16

Short BreakKort pausKurze Pause

Page 17: Lund 2015 - QGIS workshop

Workshop – Lund 2015 17

LecoS

● Simple Plugin to extract landscape metrics from raster layer● Inspired by FRAGSTAT● With Graphical interface, but more options available in

Processing Toolbox

Page 18: Lund 2015 - QGIS workshop

Workshop – Lund 2015 18

Example Data set

Use the data within the Gotland zip file

Page 19: Lund 2015 - QGIS workshop

Workshop – Lund 2015 19

Research questions

1) What is the most abundant land-cover type in the study locations?

2) How much combined forest is there in our study sites?

3) How heterogen is the landcover in our study-sites?

4) What is the distance to the Forest-edge for each of our sites?

● (Optional) Neutral Landscape Models with NLMPy

Page 20: Lund 2015 - QGIS workshop

Workshop – Lund 2015 20

Landscape analysis preparation

Landscape Layer Studylocations with 500m Buffer

Page 21: Lund 2015 - QGIS workshop

Workshop – Lund 2015 21

Research Question 1.)

● Crop your the raster dataset with your buffered Studysites

(overlapping buffers are not correctly cropped. Use DissolveDissolve first)

● Use “LecoS – Land cover statistics” to compute the “Landscape proportion” of each land cover class

● Use “Groupstats”, “QScatter” or “Statist” to get the aggregated values – Or export to csv and open with a spreadsheet program!

Page 22: Lund 2015 - QGIS workshop

Workshop – Lund 2015 22

Results Question 1.)

Results Top 3:

30 (Åkermark) Arable land→ 21 %44 (Barrskog ej på lavmark 7-15 meter) Coniferous forest →17 %32 (Betesmark) Pasture → 11 %

Page 23: Lund 2015 - QGIS workshop

Workshop – Lund 2015 23

Research Question 2.)

● Isolate all forest cover from both datasets using the raster calculator (Classes 40 – 50)

● ("Layer_Gotland@1" >= 40 AND "Layer_Gotland@1" <= 50)("Layer_Gotland@1" >= 40 AND "Layer_Gotland@1" <= 50)

● Use “LecoS – Polygon overlay” to compute the Total forest cover for each buffer

● Ether add to attribute table (Layer needs to be reloaded ) or save as csv

Page 24: Lund 2015 - QGIS workshop

Workshop – Lund 2015 24

Results Question 2.)

● On average:– 285874 m² (28.58 ha)

Page 25: Lund 2015 - QGIS workshop

Workshop – Lund 2015 25

Research Question 3.)

● In order to measure land-cover heterogeneity you have 2 options:– Ether use the Moving Window in the Processing Toolbox, select

variety and an appropriate window size

– Afterwards extract the mean for each of your buffers using the polygon-overlay

● Or– Use the LecoS polygon-overlay tool to compute a “diversity-index”

like Shannon or Simpson index for each of your buffers

Page 26: Lund 2015 - QGIS workshop

Workshop – Lund 2015 26

Research Question 3.)

Page 27: Lund 2015 - QGIS workshop

Workshop – Lund 2015 27

Research Question 4.)

The landscape modifier

● Clean Map of small pixels● Extract the forest edge of the previous

generated forest extract.● Then use the Proximity tool in the

Raster menu● Use the Save-As function (rightclick

raster) to correctly set a nodata-value● Use LecoS to extract the median values

inside the grid per buffer or point

Page 28: Lund 2015 - QGIS workshop

Workshop – Lund 2015 28

Results question 4.)

FeatureID 27 + 30 farthest away from forest edge

~ 942m and 522m

Page 29: Lund 2015 - QGIS workshop

Workshop – Lund 2015 29

(Optional) Neutral Landscape Models (NLMpy)

● LecoS has optional NLMpy support since version 1.9.3

● Neutral Landscape Models as “Nullmodel” for continuous and classified landscapes

● Publication:● onlinelibrary.wiley.com/doi/10

.1111/2041-210X.12308/full

Page 30: Lund 2015 - QGIS workshop

Workshop – Lund 2015 30

How to get the library?

● In order to install non-supported libraries you have to use PIP (python package index).

● NO Guarantee that this will work for your!● https://pypi.python.org/pypi/nlmpy

– Open the Python console in QGIS (or terminal on Linux)

– Run pip install nlmpy

– Or alternatively download and pip install nlmpy-0.1.1.tar.gz

Page 31: Lund 2015 - QGIS workshop

Workshop – Lund 2015 31

Time for Map Presentation?

Page 32: Lund 2015 - QGIS workshop

Workshop – Lund 2015 32

Running scripts in the Processing Toolbox

● The Processing toolbox (formerly called Sextante) in QGIS can be used to write models and script to do repeatable tasks

● Currently Python and R scripts are supported● In order to create a R-script, make sure that it is enabled in the

Processing options (menu)

Page 33: Lund 2015 - QGIS workshop

Workshop – Lund 2015 33

Other useful stuff - Processing R commands

Command Function

##[datagis]=group Sets the group to “datagis”

##layer = vector or raster Specifies the input layer to use

##distance=number 100 Sets a number field with default 100

##title=string France Get text input. Default is “France”

##field=field layer Select a field from the vector layer “layer”

hist(layer[[field]]) R-command: Histogram for fields from layer

##showplots Has to be set in order to see plot outputs

>t.test(layer[[field]]) Console output with a “>” before command

##output=output vector File output as vector or raster

Page 34: Lund 2015 - QGIS workshop

Workshop – Lund 2015 34

Example Script

##[Own Scripts]=group##showplots##layer=vector##y=field layer##x=field layerplot(as.numeric( layer[[y]] )~as.numeric( layer[[x]] ),pch=19,bty="l",ylab=paste( y ),xlab=paste( x ) )fit = lm( layer[[y]]~layer[[x]] )abline(fit,col="blue",lwd=2)

Page 35: Lund 2015 - QGIS workshop

Workshop – Lund 2015 35

Additional examples, help and tutorials

● http://www.gistutor.com/ ● http://qgis.spatialthoughts.com/● Youtube → search QGIS● http://gis.stackexchange.com● QGIS-user mailing list → http://lists.osgeo.org/listinfo/qgis-user

Page 36: Lund 2015 - QGIS workshop

Workshop – Lund 2015 36

Thanks for your attention!

Open questions....!