-
Notifications
You must be signed in to change notification settings - Fork 3
/
P3_rasterPackage_exercises_I-v1.html
183 lines (140 loc) · 6.53 KB
/
P3_rasterPackage_exercises_I-v1.html
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="João Gonçalves" />
<title>P3 Exercises with raster data (parts 1-2)</title>
<script src="P3_rasterPackage_exercises_I-v1_files/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="P3_rasterPackage_exercises_I-v1_files/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="P3_rasterPackage_exercises_I-v1_files/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="P3_rasterPackage_exercises_I-v1_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="P3_rasterPackage_exercises_I-v1_files/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="P3_rasterPackage_exercises_I-v1_files/navigation-1.1/tabsets.js"></script>
<link href="P3_rasterPackage_exercises_I-v1_files/highlightjs-1.1/default.css" rel="stylesheet" />
<script src="P3_rasterPackage_exercises_I-v1_files/highlightjs-1.1/highlight.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs && document.readyState && document.readyState === "complete") {
window.setTimeout(function() {
hljs.initHighlighting();
}, 0);
}
</script>
<style type="text/css">
h1 {
font-size: 34px;
}
h1.title {
font-size: 38px;
}
h2 {
font-size: 30px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 16px;
}
h6 {
font-size: 12px;
}
.table th:not([align]) {
text-align: left;
}
</style>
</head>
<body>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
height: auto;
}
.tabbed-pane {
padding-top: 12px;
}
button.code-folding-btn:focus {
outline: none;
}
</style>
<div class="container-fluid main-container">
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
</script>
<!-- code folding -->
<div class="fluid-row" id="header">
<h1 class="title toc-ignore">P3 Exercises with raster data (parts 1-2)</h1>
<h4 class="author"><em>João Gonçalves</em></h4>
<h4 class="date"><em>28 de Novembro de 2017</em></h4>
</div>
<p>Geospatial data is becoming increasingly used to solve numerous ‘real-life’ problems (check out some examples <a href="http://gisgeography.com/gis-applications-uses/%22">here</a>. In turn, R is becoming a powerful open-source solution to handle this type of data, currently providing an exceptional range of functions and tools for GIS and Remote Sensing data analysis.</p>
<p>In particular, <strong>raster data</strong> provides support for representing spatial phenomena by diving the surface into a grid (or matrix) composed by cells of regular size. Each raster dataset has a certain number of columns and rows and each cell contains a value with information for the variable of interest. Stored data can be either: (i) thematic - representing a <strong>discrete</strong> variable (e.g., land cover classification map) or <strong>continuous</strong> (e.g., elevation).</p>
<p>The <code>raster</code> package currently provides an extensive set of functions to create, read, export, manipulate and process raster datasets. It also provides low-level functionalities for creating more advanced processing chains as well as the ability to manage large datasets. For more information see: <code>vignette("functions", package = "raster")</code>.</p>
<p>Answers to the exercises are available <a href="http://r-exercises.com/2017/12/27/solutions-to-exercises-with-raster-data-parts-1-2/">here</a>.</p>
<p>You can also check more about raster data on the tutorial series about this topic <a href="http://r-exercises.com/tags/raster-data">here</a>.</p>
<p>Start by downloading, uncompressing and loading the sample data for these exercises from this <a href="https://raw.githubusercontent.com/joaofgoncalves/R_exercises_raster_tutorial/master/data/srtm_pnpg.zip">link</a> (digital elevation model data from SRTM-v4.1 for the Peneda-Geres National Park, Portugal). The data is in GeoTIFF format with name srtm_pnpg.tif.</p>
<p><strong>Exercise 1</strong><br />
Check out the size of the data in terms of number of rows, columns, cells and layers.</p>
<p><strong>Exercise 2</strong><br />
Check the spatial resolution of the raster and its coordinate reference system (CRS).</p>
<p><strong>Exercise 3</strong><br />
Get the raster extent object and calculate the ‘height’ (in the y-axis) and the length (in x-axis) of the raster.</p>
<p><strong>Exercise 4</strong><br />
Calculate the mean and standard-deviation for all pixels.</p>
<p><strong>Exercise 5</strong><br />
Calculate the 1%, 25%, 50%, 75% and 99% quantiles for all pixels.</p>
<p><strong>Exercise 6</strong><br />
Using a QQ-plot investigate deviations from normality in the distribution of elevation values.</p>
<p><strong>Exercise 7</strong><br />
Extract raster values for 100 randomly generated points within the image (use <code>set.seed(12345)</code>)<br />
for obtaining the same values as in the solutions).</p>
<p><strong>Exercise 8</strong><br />
Convert the elevation units of the DEM from meters to feet. Make a RasterStack object with both the raster with meters (original) and feet (new).</p>
<p><strong>Exercise 9</strong><br />
Crop the raster to the following extent: Upper-left {ymax = 4654705, xmin = 554615}, and, Lower-right {ymin = 4618355, xmax = 589015}.</p>
<p><strong>Exercise 10</strong><br />
Reproject the sample raster to Datum ETRS 1989 (European Terrestrial Reference System 1989), projection Lambert Azimuthal Equal Area (LAEA) and change the resolution to 100m with bilinear method.</p>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>