-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow_learning-intensity-analysis.R
92 lines (78 loc) · 3.37 KB
/
workflow_learning-intensity-analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# This script implements a land cover change analysis workflow using the Intensity
# Analysis framework via the intensity.analysis R package (Pontius & Khallaghi 2019).
# The script uses land cover image datasets from one of my land cover change studies
# investigating land-cover regime shifts in Tanintharyi Region, Myanmar, published
# in Sustainability journal (https://doi.org/10.3390/su11041139).
#
# Script modified by: Jose Don T. De Alban
# Date created: 30 May 2019
# Date modified: 13 Jun 2019
# ----------------------------------------
# SET WORKING DIRECTORY
# ----------------------------------------
setwd("/Users/dondealban/Dropbox/Research/learning-intensity-analysis/")
# ----------------------------------------
# LOAD LIBRARIES
# ----------------------------------------
library(raster)
library(intensity.analysis)
# ----------------------------------------
# LOAD RASTER DATA
# ----------------------------------------
setwd("/Users/dondealban/Dropbox/Research/learning-intensity-analysis/raster data/")
r1992 <- raster('Landscape_1992.tif')
r1997 <- raster('Landscape_1997.tif')
r2004 <- raster('Landscape_2004.tif')
r2015 <- raster('Landscape_2015.tif')
# Copy raster data into new variables
lc1992 <- r1992
lc1997 <- r1997
lc2004 <- r2004
lc2015 <- r2015
# Set 0 pixel values ('No Data') of raster data copies to NA
lc1992[lc1992 <= 0] <- NA
lc1997[lc1997 <= 0] <- NA
lc2004[lc2004 <= 0] <- NA
lc2015[lc2015 <= 0] <- NA
# ----------------------------------------
# CREATE LISTS AND VECTORS
# ----------------------------------------
raster.layers <- list(lc1992, lc1997, lc2004, lc2015) # Create a list of raster data
time.points <- c("1992","1997","2004","2015") # Create character vector of time-points
categories <- c("Forest",
"Mosaic Vegetation",
"Shrubland",
"Other Vegetation",
"Cropland",
"Non-Vegetation") # Create character vector of land cover categories
# ----------------------------------------
# CROSS-TABULATION
# ----------------------------------------
crosstabulation <- multicrosstab(raster.layers, time.points, categories)
# ----------------------------------------
# INTENSITY ANALYSIS
# ----------------------------------------
# Interval-level Intensity Analysis
IIA.output <- IIA(crosstabulation, time.points)
# Category-level Intensity Analysis
CIA.output <- CIA(crosstabulation, time.points, categories)
# Transition-level Intensity Analysis
TIA.output <- TIA(crosstabulation, time.points, categories)
# ----------------------------------------
# SAVE OUTPUT CSV FILES
# ----------------------------------------
setwd("/Users/dondealban/Dropbox/Research/learning-intensity-analysis/outputs/")
IIAname <- file.path(normalizePath(getwd()), "IIA.csv")
IIA2csv(IIA.output, time.points, IIAname)
CIAname <- file.path(normalizePath(getwd()), "CIA.csv")
CIA2csv(CIA.output, time.points, categories, CIAname)
TIAname <- file.path(normalizePath(getwd()), "TIA.csv")
TIA2csv(TIA.output, time.points, categories, TIAname)
# Save the cross-tabulation matrices
setwd("/Users/dondealban/Dropbox/Research/learning-intensity-analysis/outputs/")
crosstab_1 <- crosstabulation[[1]] #1992-1997
write.csv(crosstab_1, "CrossTab_I1.csv")
crosstab_2 <- crosstabulation[[2]] #1997-2004
write.csv(crosstab_2, "CrossTab_I2.csv")
crosstab_3 <- crosstabulation[[3]] #2004-2015
write.csv(crosstab_3, "CrossTab_I3.csv")