Project

General

Profile

Download (36.5 KB) Statistics
| Branch: | Revision:
1
% -*- mode: noweb; noweb-default-code-mode: R-mode; -*-
2
%
3
% Using Gregor Gorjanc's bash script:
4
%   sweave -old=<pdfviewer> <filename.Rnw>
5
%
6
% Using my simple bash script wrapper:
7
%   sweave_jr <basename>
8
%
9
% Using the lower level commands, in two steps: 
10
%   R CMD Sweave <filename.Rnw>
11
%   pdflatex <filename.tex>
12
%
13
% To extract R code from within R:
14
%   Stangle("<filename.Rnw>", annotate=FALSE)
15
\documentclass{article}
16
\usepackage[font=small,labelfont=bf]{caption}
17
\usepackage[font=normalsize,singlelinecheck=false]{subfig}
18
\usepackage{enumitem}
19
\usepackage[utf8]{inputenc}
20
\usepackage{a4wide}
21
\usepackage{verbatim}
22
\usepackage{listings}
23
\usepackage[colorlinks=true,urlcolor=red]{hyperref}
24
\usepackage{color}
25
\usepackage{xspace}
26

    
27
% shrink list item spacing
28
\setlist{noitemsep}
29

    
30
% set some listings options
31
\lstset{
32
  basicstyle=\footnotesize\ttfamily,
33
  stringstyle=\ttfamily,
34
  commentstyle=\itshape\ttfamily,
35
  showstringspaces=false,
36
}
37

    
38
% define degree command for convenience
39
\newcommand{\N}{\ensuremath{^\circ\mbox{N}}\xspace}
40
\newcommand{\W}{\ensuremath{^\circ\mbox{W}}\xspace}
41

    
42
% add page numbers, but no headers
43
\thispagestyle{plain}
44

    
45
\title{SRTM/ASTER boundary analysis}
46
\author{Jim Regetz, NCEAS}
47
\date{Last update: 13 Jul 2011}
48

    
49
\begin{document}
50

    
51
\maketitle
52

    
53
% don't number document sections
54
\setcounter{secnumdepth}{-1}. 
55

    
56
% first compute some values to use in the text
57
<<echo=FALSE,results=hide>>=
58
  # Gaussian weighted average parameters
59
  gwa.r <- 0.001
60
  gwa.50.pix <- round(sqrt(-log(0.5)/gwa.r))
61
  gwa.50.km <- gwa.50.pix * 90 / 1000
62
  gwa.01.pix <- round(sqrt(-log(0.01)/gwa.r))
63
  gwa.01.km <- gwa.01.pix * 90 / 1000
64

    
65
  # mean/median ASTER-SRTM elevation differences
66
  library(raster)
67
  demdir <- "/home/regetz/media/temp/terrain/dem/"
68
  d.srtm <- raster(file.path(demdir, "srtm_150below.tif"))
69
  d.aster <- raster(file.path(demdir, "aster_300straddle.tif"))
70
  d.delta.vals <- values(crop(d.aster, extent(d.srtm))) - values(d.srtm)
71
  delta.median <- median(d.delta.vals)
72
  delta.mean <- mean(d.delta.vals)
73
  delta.sd <- sd(d.delta.vals)
74
  delta.q <- quantile(d.delta.vals, c(0.1, 0.25, 0.75, 0.9))
75
@
76

    
77
\paragraph{Brief summary of findings}
78
\begin{itemize}
79
 \item SRTM vs ASTER differences
80
  \begin{itemize}
81
   \item ASTER is systematically lower, by 12 meters in the median case
82
   \item \ldots but with variability: standard deviation of
83
     $\mbox{ASTER}_i-\mbox{SRTM}_i$ is \Sexpr{round(delta.sd, 1)}
84
   \item ASTER also has numerous spurious spikes
85
   \item ASTER has more high-frequency variability (``texture''),
86
     affecting slope/aspect?
87
  \end{itemize}
88
 \item Fusion via northward exponential rampdown of boundary delta
89
  \begin{itemize}
90
   \item eliminates elevation cliff at 60\N
91
   \item leaves abrupt transition in SRTM/ASTER textural differences
92
   \item introduces north-south ridging artifacts
93
   \item (\emph{no further treatment in this document})
94
  \end{itemize}
95
 \item Fusion via multiresolution spline
96
  \begin{itemize}
97
   \item eliminates elevation cliff at 60\N
98
   \item leaves abrupt transition in derived slope and aspect
99
   \item unclear whether derived values of aspect and flow direction
100
     in the transition zone are acceptable
101
  \end{itemize}
102
 \item Fusion via Gaussian weighted average of SRTM/ASTER
103
  \begin{itemize}
104
   \item eliminates elevation cliff at 60\N
105
   \item also smooths transition slope and aspect
106
   \item unclear whether derived values of aspect and flow direction in
107
     the transition zone are acceptable
108
  \end{itemize}
109
 \item Canada DEM itself has problems
110
  \begin{itemize}
111
   \item 60\N coincides with provincial boundaries; there are
112
     clear 60\N artifacts in this layer!
113
   \item other evident tiling artifacts too
114
  \end{itemize}
115
 \item Other comments
116
  \begin{itemize}
117
   \item N/S bias to aspect, flow direction computed on unprojected data
118
     at higher latitudes?
119
  \end{itemize}
120
\end{itemize}
121

    
122
\paragraph{To do (possibly)}
123
\begin{itemize}
124
 \item add constant offset of \Sexpr{-delta.median}m to ASTER
125
 \item apply low pass filter to ASTER to reduce high frequency
126
 variation?
127
 \item apply algorithm to remove spikes (\ldots but maybe beyond scope?)
128
\end{itemize}
129

    
130
\clearpage
131

    
132
%-----------------------------------------------------------------------
133
\section{Terrain layer production methodology}
134
%-----------------------------------------------------------------------
135

    
136
For the purposes of assessing artifacts associated with the northern
137
boundary between SRTM and ASTER, I focused on a narrow band along the
138
60\N boundary in Canada (Figure \ref{focal-area}). The latitudinal
139
extent of this band is 59.875\N - 60.125\N (i.e., 300 3" pixels
140
straddling 60\N), and the longitudinal extent is 136\W to 96\W (i.e.,
141
48,000 pixels wide). See Listing \ref{code-gdalwarp} for code. Within
142
this focal region, I generated latitudinal profiles of mean elevation,
143
slope, aspect, and flow direction, using the separate SRTM and ASTER
144
component DEMs themselves, using several different fused ASTER/SRTM DEMs
145
(see below), and using the Canadian Digital Elevation Data (CDED) as an
146
independent reference layer
147
(\url{http://www.geobase.ca/geobase/en/data/cded/index.html}). I also
148
then computed latitudinal correlations and RMSEs between the fused
149
layers and each of SRTM, ASTER, and CDED.
150

    
151
\paragraph{Elevation} This document includes latitudinal
152
characterizations of terrain values based on three different variants of
153
a fused 3" ASTER/SRTM DEM. I also explored (and briefly describe below) two
154
additional approaches to fusing the layers, but do not include further
155
assessment of these here.
156

    
157
\subparagraph{Simple fusion} Naive concatenation of SRTM below 60\N with
158
ASTER above 60\N, without applying any modifications to deal with
159
boundary artifacts (Figure \ref{blend-simple}).
160

    
161
\subparagraph{Multiresolution spline} Application of Burt \& Adelson's
162
(1983) method for blending overlapping images using multiresolution
163
splines, as implemented in the \emph{Enblend} software package (version
164
4.0, \url{http://enblend.sourceforge.net}). Data preparation and
165
post-processing were handled in R (see Listing \ref{code-enblend}). As
166
presented here, the SRTM and ASTER inputs were prepared such that the
167
overlap zone is 75 latitudinal rows (6.75km) (Figure
168
\ref{blend-multires}).
169

    
170
\subparagraph{Gaussian weighted average} Blend of the two layers using
171
weighted averaging such that the relative contribution of the SRTM
172
elevation is zero at 60\N, and increases as a function of distance
173
moving south away from 60\N (Equation \ref{eq-gaussian}).
174
\begin{eqnarray}
175
\label{eq-gaussian}
176
&fused_{x,y} =
177
  \left\{
178
    \begin{array}{c l}
179
      ASTER_{x,y} & \mbox{above } 60^\circ \mbox{N} \\
180
      w_{x,y}ASTER_{x,y} + (1-w_{x,y})SRTM_{x,y} & \mbox{below } 60^\circ \mbox{N}
181
    \end{array}
182
  \right.\\
183
&\mbox{where }
184
  w_{x,y}=e^{-rD_{y}^{2}}
185
  \mbox{ and }
186
  D_{y} \mbox{ is the distance from } 60^\circ \mbox{N in units of pixels.} \nonumber
187
\end{eqnarray}
188
For the assessment presented here, the weighting function function was
189
parameterized using $r$=\Sexpr{gwa.r}, producing equal weights for SRTM
190
and ASTER at a distance of $\sim$\Sexpr{round(gwa.50.km, 1)}km
191
(\Sexpr{gwa.50.pix} cells) south of the the boundary, and a relative
192
weight for ASTER of only 1\% by $\sim$\Sexpr{round(gwa.01.km, 1)}km
193
(\Sexpr{gwa.01.pix} cells) (Figure \ref{blend-gaussian}). See
194
\texttt{OPTION 3} in Listing \ref{code-correct}.
195

    
196
\subparagraph{Others not shown} I also experimented with some additional
197
fusion approaches, but have excluded them from further analysis in this
198
document.
199

    
200
\emph{Fused with exponential ramp north of 60\N.}
201
The first step was to take the pixel-wise difference between SRTM and
202
ASTER in the row immediately below 60\N (i.e., the northernmost extent of
203
SRTM). An exponentially declining fraction of this difference was then
204
then added back into the ASTER values north of 60\N. This does a fine
205
job of eliminating the artificial shelf and thus the appearance of a
206
seam right along the 60\N boundary, but it does not address the abrupt
207
transition in texture (i.e., the sudden appearance of high frequency
208
variability moving north across the boundary). Additionally, it
209
introduces vertical ``ridges'' running north from the boundary. These
210
arise because the calculated ramps are independent from one longitudinal
211
``column'' to the next, and thus any changes in the boundary difference
212
from one pixel to the next lead to adjacent ramps with different
213
inclines.
214

    
215
\emph{Simple LOESS predictive model.}
216
This involved first calculating the difference between SRTM and ASTER
217
everywhere south of 60\N, and then fitting a LOESS curve to these
218
differences using the actual ASTER elevation as a predictor. I then used
219
the fitted model to predict the ASTER-SRTM difference for each ASTER
220
cell north of 60\N, and added a declining fraction (based on a Gaussian
221
curve) of this difference to the corresponding ASTER elevation.
222
Conceptually, this amounts to applying an ASTER-predicted SRTM
223
correction to the ASTER elevation values, where the correction term has
224
a weight that declines to zero with increasing distance (north) away
225
from the boundary. However, this method alone didn't yield particularly
226
promising results in removing the 60\N seam itself, presumably because
227
adding a predicted correction at the boundary does not close the
228
SRTM-ASTER gap nearly as efficiently as do corrections based directly on
229
the observed SRTM vs ASTER elevation differences. I therefore haven't
230
pursued this any further, although it (or something like it) may prove
231
useful in combination with one of the other methods.
232

    
233
\paragraph{Slope}
234
For each of the three main fused DEM variants described above, slope was
235
calculated using \texttt{gdaldem} (GDAL 1.8.0, released 2011/01/12):
236
\begin{verbatim}
237
    $ gdaldem slope -s 111120 <input_elevation> <output_slope>
238
\end{verbatim}
239
Note that the scale option used here is as recommended in the
240
\texttt{gdaldem} documentation:
241
\begin{quote}
242
  ``\emph{If the horizontal unit of the source DEM is degrees (e.g
243
  Lat/Long WGS84 projection), you can use scale=111120 if the vertical'
244
  units are meters}''
245
\end{quote}
246
The output slope raster is in units of degrees.
247

    
248
\paragraph{Aspect}
249
As was the case with slope, aspect was calculated using
250
\texttt{gdaldem}:
251
\begin{verbatim}
252
    $ gdaldem aspect -s 111120 <input_elevation> <output_aspect>
253
\end{verbatim}
254
The output aspect raster values indicate angular direction in units of
255
degrees, with 0=North and proceeding clockwise.
256

    
257
\paragraph{Flow direction}
258

    
259
Flow direction was calculated using the GRASS (GRASS GIS 6.4.1)
260
\texttt{r.terraflow} module; see code listing \ref{code-flowdir}.
261
Because of a $\sim$30k ($2^{15}$) limit to the input raster dimension
262
size in the pre-built GRASS \texttt{r.terraflow} module I used, this
263
analysis was restricted to a smaller longitudinal subset of the data,
264
spanning 125\W to 100\W.
265

    
266
The default flow direction output of this module is encoded so as to
267
indicate \emph{all} downslope neighbors, also known as the Multiple Flow
268
Direction (MFD) model. However, to simplify post-processing and
269
summarization, the results here are based on an alternative Single Flow
270
Direction (SFD, \emph{a.k.a.} D8) model, which indicates the neighbor
271
associated with the steepest downslope gradient. Note that this is
272
equivalent to what ArcGIS GRID \texttt{flowaccumulation} command does. I
273
then recoded the output raster to use the same azimuth directions used
274
by \texttt{gdaldem aspect}, as described above for aspect.
275

    
276

    
277
%-----------------------------------------------------------------------
278
\section{Latitudinal mean terrain profiles}
279
%-----------------------------------------------------------------------
280

    
281

    
282
\paragraph{Elevation} SRTM, ASTER, and CDED all share a very
283
similarly shaped mean elevation profile, but with differing heights
284
(Figure \ref{mean-elevation}). SRTM tends to be highest, ASTER is
285
lowest, and CDED is intermediate. The magnitude of average difference
286
between SRTM and ASTER is fairly consistent not only across latitudes,
287
but also across elevations (Figure \ref{aster-srtm}). The overall median
288
difference between ASTER and SRTM (i.e., considering
289
$\mbox{ASTER}_i-\mbox{SRTM}_i$ for all pixels $i$ where the two DEMs
290
co-occur) is \Sexpr{delta.median} meters, with a mean of
291
\Sexpr{round(delta.mean, 2)}, and this more or less holds (within a few
292
meters) across the observed range of elevations (Figure
293
\ref{aster-srtm-bins}). However, while this average offset is broadly
294
consistent across latitudes and across elevation zones, additional
295
variation is evident at the pixel level. Again focusing on the
296
pixel-wise differences, they appear to be symmetrically distributed
297
about the mean with a standard deviation of \Sexpr{round(delta.sd, 1)}
298
and quartiles ranging from \Sexpr{delta.q["25%"]} to
299
\Sexpr{delta.q["75%"]} meters; ASTER elevations are actually greater
300
than SRTM for \Sexpr{round(100*mean(d.delta.vals>0))}\% of pixels (see
301
Figure \ref{aster-srtm-scatter}). Thus, although adding a constant
302
offset of \Sexpr{-delta.median} meters to the ASTER DEM would clearly
303
center it with respect to the SRTM (at least in the Canada focal
304
region), appreciable differences would remain. Figure
305
\ref{aster-srtm-scatter} also highlights the existence of several
306
obviously spurious ASTER spikes of >1000m; although not shown here,
307
these tend to occur in small clumps of pixels, perhaps corresponding to
308
false elevation readings associated with clouds?
309

    
310
Not surprisingly, simple fusion produces an artificial $\sim$12m cliff
311
in the mean elevation profile (Figure \ref{mean-elevation}). At least in
312
terms of mean elevation, this artifact is completely removed by both the
313
multiresolution spline and Gaussian weighted average methods. The
314
transition is, to the eye, slightly smoother in the former case,
315
although ultimately this would depend on the chosen zone of overlap and
316
on the exact parameterization of the weighting function.
317

    
318
\paragraph{Slope} The mean ASTER slope is uniformly steeper than the
319
mean SRTM slope at all latitudes in the area of overlap, by nearly 1
320
degree (Figure \ref{mean-slope}). However, the shape of the profile
321
itself is nearly identical between the two. Although this may partly
322
reflect inherent SRTM vs ASTER differences, my guess is that CGIAR
323
post-processing of the particular SRTM product we're using has removed
324
some of the high frequency ``noise'' that remains in ASTER?
325
\textbf{\color{red}[todo: check!]}
326

    
327
Note that the CDED tends to be flatter than both SRTM and
328
ASTER (presumably because it is at least partially derived from
329
contour-based data \textbf{\color{red}[todo: check!]}). Moreover, this
330
figure makes it clear that CDED has some major artifacts at
331
regular intervals. The spike especially at 60\N (which coincides with
332
provincial boundaries across the entirety of western Canada) means we
333
probably need to scuttle our plans to use this DEM as a formal reference
334
dataset for boundary analysis.
335

    
336
The simple fused layer exhibits a dramatic spike in slope at the
337
immediate 60\N boundary, undoubtedly associated with the artificial
338
elevation cliff. This artifact is eliminated by both the multiresolution
339
spline and Gaussian weighting. However, the former exhibits a sudden step
340
change in slope in the SRTM-ASTER overlap region, whereas the transition
341
is smoothed out in the latter. This likely reflects the fact that the
342
multiresolution spline effectively uses a very narrow transition zone
343
for stitching together high frequency components of the input images,
344
and it seems likely that these are precisely the features responsible
345
for the shift in mean slope. 
346

    
347
\paragraph{Aspect}
348
For the purposes of latitudinal profiles, aspect values were summarized
349
using a circular mean (Equation \ref{eq-cmean}).
350
\begin{equation}
351
 \bar{x} = \mathrm{atan2}
352
   \left(
353
    \sum_{i=1}^{n}\frac{\sin(x_i)}{n},
354
    \sum_{i=1}^{n}\frac{\cos(x_i)}{n}
355
   \right )
356
\label{eq-cmean}
357
\end{equation}
358
where $x_i$ is the aspect value (in radians) of pixel $i$.
359

    
360
As indicated in Figure \ref{mean-aspect}, the circular mean aspect
361
values of SRTM and ASTER are generally similar across all latitudes in
362
the area of overlap, and mean aspect values calculated on CDED
363
are similar at most but not all latitudes. The mean values at nearly all
364
latitudes are directed either nearly north or nearly south, though
365
almost always with a slight eastward rather than westward inclination.
366
In fact, there appears to be a general bias towards aspect values
367
orienting along the north-south axis, as is especially apparent in the
368
rose diagrams of Figure \ref{rose-diag-aspect}. I suspect this is an
369
artifact of our use of unprojected data, especially at these high
370
latitudes. Because the unprojected raster is effectively 'stretched'
371
east and west relative to the actual topography, elevational gradients
372
along the east-west axis are artificially flattened, and the direction
373
of dominant gradient is more likely to be along the north-south axis.
374

    
375
Upon further reflection, it's not clear whether these patterns of mean
376
aspect are particular useful diagnostics, as they seems to be sensitive
377
to subtle variations in the data. Referring again to Figure
378
\ref{rose-diag-aspect}, note how the mean direction flips from nearly
379
north to nearly south between the two latitudes, even though the
380
distributions of pixel-wise aspect values are nearly indistinguishable
381
by eye.
382

    
383
In any case, not surprisingly, the simple fused layer matches the SRTM
384
aspect values south of 60\N and the ASTER aspect values north of 60\N; at
385
the immediate boundary, the mean aspect is northward, as one would
386
expect in the presence of a cliff artifact at the seam.
387

    
388
Interestingly, the aspect layers derived from the two blended DEMs
389
(multiresolution spline and Gaussian weighted average) exhibit a
390
consistent mean northward inclination at all latitudes in their
391
respective fusion zones. This pattern is visually obvious at latitudes
392
between 59.95\N and 60\N in the bottom two panels of Figure
393
\ref{mean-aspect}. This is almost certainly a signal of the blending of
394
the lower elevation ASTER to the north with higher elevation SRTM to the
395
south, introducing a north-facing tilt (however slight) to the data
396
throughout this zone. 
397

    
398
\paragraph{Flow direction} With the exception of edge effects at the
399
margins of the input rasters, mean ASTER-derived flow is nearly
400
northward at all latitudes, and SRTM-derived flow is nearly northward at
401
all but a few latitudes (Figure \ref{mean-flowdir}). This seems
402
reasonable considering that most pixels in this Canada test region fall
403
in the Arctic drainage. For unknown reasons, CDED produces southward
404
mean flow direction at numerous latitudes, and generally seems to have a
405
slightly more eastward tendency. As was the case with aspect, note that
406
a general north-south bias is evident (Figure \ref{rose-diag-flowdir}),
407
again likely due to use of an unprojected raster at high latitudes.
408

    
409
The various fused layer profiles look as one would expect (Figure
410
\ref{mean-flowdir}), although the overall lack of latitudinal
411
variability in mean flow direction in SRTM, ASTER, and all three derived
412
layers makes it hard to say much more than that. 
413

    
414
%-----------------------------------------------------------------------
415
\section{Informal correlation analysis}
416
%-----------------------------------------------------------------------
417

    
418
\paragraph{Elevation}
419
Pearson correlations between SRTM and ASTER are quite high, typically
420
>0.999, and RMSEs are on the order of 10-15 meters (Figures
421
\ref{corr-elevation} and \ref{rmse-elevation}). Spikes (downward for
422
correlation, upward for RMSE) occur at some latitudes, quite possibly
423
associated with the observed extreme spikes in the ASTER DEM itself. As
424
expected, the multiresolution spline and Gaussian weighted average both
425
produce layers that gradually become less similar to ASTER and more
426
similar to SRTM moving south from 60\N, but in slightly different ways.
427
This gradual transition is less evident when considering associations
428
with CDED (bottom panels of Figures \ref{corr-elevation} and
429
\ref{rmse-elevation}), which in general is less correlated with SRTM,
430
and even less with ASTER, than those two layers are with each other.
431

    
432
\paragraph{Slope}
433
The patterns of slope layer similarity are much like those described
434
above for elevation, although the correlations are somewhat lower
435
($\sim$0.94 between SRTM and ASTER (Figure \ref{corr-slope})). RMSEs
436
between SRTM and ASTER are approximately 2 at all latitudes where the
437
data co-occur (Figure \ref{rmse-slope}). Another difference, echoing a
438
pattern previously noted in the profiles of mean slope itself, is that
439
Gaussian weighted averaging produces a layer that exhibits a gradual
440
transition from ASTER to SRTM, whereas the multiresolution spline yields
441
an abrupt transition. Not surprisingly, the simple fused layer is even
442
worse, producing not only a sudden transition but also aberrant values
443
at the fusion seam itself; note downward (upward) spikes in correlation
444
(RMSE) at 60\N in the first column of plots in Figures \ref{corr-slope}
445
and \ref{rmse-slope}.
446

    
447
\paragraph{Aspect}
448
Because aspect values are on a circular scale, I calculated modified
449
versions of the Pearson correlation coefficient using the
450
\textbf{circular} R package function \texttt{cor.circular}. I believe
451
this implements the formula described by Jammalamadaka \& Sarma (1988):
452
\begin{equation}
453
r = \frac
454
  {\sum_{i=1}^{n} \sin(x_i-\bar{x}) \sin(y_i-\bar{y})}
455
  {\sqrt{\sum_{i=1}^{n} \sin(x_i-\bar{x})^2}
456
   \sqrt{\sum_{i=1}^{n} \sin(y_i-\bar{y})^2}}
457
\label{eq-ccor}
458
\end{equation}
459
where $x_i$ and $y_i$ are aspect values (in radians) for pixel $i$, and
460
$\bar{x}$ and $\bar{y}$ are circular means calculated as in Equation
461
\ref{eq-cmean}.
462

    
463
To calculate RMSEs for aspect, I did not attempt to use trigonometric
464
properties analogous to computation of the circular correlation, but
465
instead just imposed a simple correction whereby all pairwise
466
differences were computed using the shorter of the two paths around the
467
compass wheel (Equation \ref{eq-circ-rmse}). For example, the difference
468
between 0$^\circ$ and 150$^\circ$ is 150$^\circ$, but the difference
469
between 0$^\circ$ and 250$^\circ$ is 110$^\circ$.
470

    
471
\begin{eqnarray}
472
\label{eq-circ-rmse}
473
&RMSE = \sqrt{\frac{\sum_{i=1}^{n} (\Delta_i^2)}{n}}\\ \nonumber
474
&\mbox{where }
475
  \Delta_i = \mbox{argmin} \left (|x_i-y_i|, 360-|x_i - y_i| \right )
476
\end{eqnarray}
477

    
478
Circular correlations between SRTM and ASTER were surprisingly low,
479
typically hovering around 0.5, but dipping down towards zero at numerous
480
latitudes (Figure \ref{corr-flowdir}). The corresponding RMSE is close
481
to 70 at all latitudes, surprisingly high considering that the maximum
482
difference between any two pixels is 180$^\circ$ (Figure
483
\ref{rmse-flowdir}). Comparison of SRTM and ASTER with CDED
484
yields similar patterns.
485

    
486
For both of the blended layers (multiresolution spline and Gaussian
487
weighted average), aspect values calculated in the zone of ASTER/SRTM
488
overlap appear to be \emph{less} similar to the component DEMs than
489
those to data sources are to each other. As evident in the upper middle
490
and upper right panels of Figure \ref{corr-flowdir}, correlations
491
between fused aspect and aspect based on the original SRTM and ASTER
492
images are substantially \emph{negative} for many latitudes in the zone
493
of overlap. I don't have a good feel for what's going on here, although
494
it may just involve properties of the circular correlation statistic
495
that I don't have a good feel for. Note that the latitudinal profile of
496
aspect RMSEs is less worrisome (upper middle and upper right panels of
497
Figure \ref{rmse-flowdir}) and more closely resembles the profile of
498
slope RMSEs discussed above, particularly as regards the more gradual
499
transition in case of Gaussian weighted averaging compared to the
500
multiresolution spline.
501

    
502
\paragraph{Flow direction}
503
As with aspect, circular correlation coefficients and adjusted RMSEs
504
were calculated for each latitudinal band. Flow direction correlations
505
between SRTM and ASTER are slightly lower than for aspect, typically
506
around 0.40 but spiking negative at a handful of latitudes (Figure
507
\ref{corr-flowdir}). RMSEs hover consistently around $\sim$75, slightly
508
lower than was the case with aspect (Figure \ref{rmse-flowdir}).
509

    
510
Aside from an expected flow artifact at the southern image edge, and an
511
unexpected (and as-yet unexplained) negative spike at $\sim$59.95\N, the
512
correlation profiles are fairly well-behaved for both blended layers,
513
and don't show the same odd behavior as was the case for aspect. Again
514
it is clear that the multiresolution spline results in a much more abrupt
515
transition than does the Gaussian weighted average. The RMSE flow
516
direction profiles echo this pattern (Figure \ref{rmse-flowdir}), and
517
indeed look almost the same as those computed using aspect (Figure
518
\ref{rmse-aspect}).
519

    
520
%-----------------------------------------------------------------------
521
% FIGURES
522
%-----------------------------------------------------------------------
523

    
524
\clearpage
525

    
526
%
527
% Figure: Boundary analysis region
528
%
529
\begin{figure}[h]
530
  \caption{Focal area}
531
  \centering
532
<<echo=FALSE,results=hide,fig=TRUE,height=5,width=7>>=
533
  par(omi=c(0,0,0,0))
534
  library(raster)
535
  library(maps)
536
  demdir <- "/home/regetz/media/temp/terrain/dem/"
537
  dem <- raster(file.path(demdir, "fused_300straddle.tif"))
538
  map("world", xlim=c(-140,-70), ylim=c(40, 70), fill=TRUE, col="grey",
539
      mar=c(4,0,0,0))
540
  grid(col="darkgray")
541
  axis(1)
542
  axis(2)
543
  box()
544
  plot(extent(dem), col="red", add=TRUE)
545
  arrows(-110, 57, -113, 59.7, col="red", length=0.1)
546
  text(-110, 57, labels="focal region", col="red", font=3, pos=1)
547
@
548
  \label{focal-area}
549
\end{figure}
550

    
551
%
552
% Figure: Fusion methods
553
%
554
\begin{figure}
555
  \caption{SRTM/ASTER DEM fusion configurations}
556
  \centering
557
  \subfloat[Simple fusion]{
558
    \label{blend-simple}
559
<<echo=FALSE,results=hide,fig=TRUE, height=3, width=6>>=
560
  par(omi=c(0,0,0,0), mar=c(4,4,0,2)+0.1)
561
  plot(0, xlim=c(-150, 150), ylim=c(0, 1), type="n", xaxt="n", yaxt="n",
562
      bty="n", xlab="Latitude", ylab=NA)
563
  rect(0, 0, 150, 0.75, col="red", density=5, angle=45)
564
  rect(-150, 0, 0, 0.75, col="blue", density=5, angle=135)
565
#  axis(1, at=seq(-120, 120, by=60), labels=seq(59.9, 60.1, by=0.05))
566
  axis(1, at=seq(-150, 150, by=75), labels=c(59.875, NA, 60, NA, 60.125))
567
  text(-150, 0.9, labels="SRTM", pos=4, col="blue")
568
  text(150, 0.9, labels="ASTER", pos=2, col="red")
569
@
570
  }\\
571
  \subfloat[Multiresolution spline]{
572
    \label{blend-multires}
573
<<echo=FALSE,results=hide,fig=TRUE, height=3, width=6>>=
574
  par(omi=c(0,0,0,0), mar=c(4,4,0,2)+0.1)
575
  plot(0, xlim=c(-150, 150), ylim=c(0, 1), type="n", xaxt="n", yaxt="n",
576
      bty="n", xlab="Latitude", ylab=NA)
577
  rect(-75, 0, 0, 0.75, col="lightgray")
578
  rect(-75, 0, 150, 0.75, col="red", density=5, angle=45)
579
  rect(-150, 0, 0, 0.75, col="blue", density=5, angle=135)
580
  #axis(1, at=seq(-150, 150, by=60), labels=seq(59.875, 60.125, by=0.05))
581
  #axis(1, at=0, labels=60, col="red", cex=0.85)
582
  #axis(1, at=seq(-120, 120, by=60), labels=seq(59.9, 60.1, by=0.05))
583
  axis(1, at=seq(-150, 150, by=75), labels=c(59.875, NA, 60, NA, 60.125))
584
  text(-150, 0.9, labels="SRTM", pos=4, col="blue")
585
  text(-37.5, 0.8, labels="overlap", pos=3, font=3)
586
  text(150, 0.9, labels="ASTER", pos=2, col="red")
587
@
588
  }\\
589
  \subfloat[Gaussian weighted average]{
590
    \label{blend-gaussian}
591
<<echo=FALSE,results=hide,fig=TRUE, height=3, width=6>>=
592
  par(omi=c(0,0,0,0), mar=c(4,4,1,2)+0.1)
593
  curve(exp(-0.001*x^2), from=-150, to=0, xlim=c(-150, 150), col="red",
594
      xaxt="n", bty="n", xlab="Latitude", ylab="Weighting")
595
  curve(1+0*x, from=0, to=150, add=TRUE, col="red")
596
  curve(1-exp(-0.001*x^2), from=-150, to=0, add=TRUE, col="blue")
597
  #axis(1, at=seq(-150, 150, by=60), labels=seq(59.875, 60.125, by=0.05))
598
  #axis(1, at=0, labels=60, col="red", cex=0.85)
599
  #axis(1, at=seq(-120, 120, by=60), labels=seq(59.9, 60.1, by=0.05))
600
  axis(1, at=seq(-150, 150, by=75), labels=c(59.875, NA, 60, NA, 60.125))
601
  text(-100, 0.6, labels="gaussian\nblend")
602
  text(-140, 0.9, labels="SRTM", col="blue", pos=4)
603
  text(-140, 0.1, labels="ASTER", col="red", pos=4)
604
@
605
  }
606
\end{figure}
607

    
608
%
609
% Figure: Mean latitudinal profiles
610
%
611
\begin{figure}
612
  \centering
613
  \caption{Mean elevation (m)}
614
    \includegraphics[page=1, trim=1in 1in 1in 1in, width=\linewidth]{../dem/elevation-assessment.pdf}
615
    \label{mean-elevation}
616
\end{figure}
617
\begin{figure}
618
  \centering
619
  \caption{Mean slope (degrees)}
620
    \includegraphics[page=1, trim=1in 1in 1in 1in, width=\linewidth]{../slope/slope-assessment.pdf}
621
    \label{mean-slope}
622
\end{figure}
623
\begin{figure}
624
  \centering
625
  \caption{Circular mean aspect (azimuth)}
626
    \includegraphics[page=1, trim=1in 1in 1in 1in, width=\linewidth]{../aspect/aspect-assessment.pdf}
627
    \label{mean-aspect}
628
\end{figure}
629
\begin{figure}
630
  \centering
631
  \caption{Circular mean flow direction}
632
    \includegraphics[page=1, trim=1in 1in 1in 1in, width=\linewidth]{../flow/flowdir-assessment.pdf}
633
    \label{mean-flowdir}
634
\end{figure}
635

    
636
%
637
% Figure: ASTER vs SRTM elevation patterns
638
%
639
\begin{figure}
640
  \caption{ASTER vs SRTM elevation comparisons}
641
  \centering
642
  \subfloat[Boxplots of the arithmetic difference in elevations (ASTER -
643
  SRTM), summarized across a series of SRTM elevation bins. Boxes
644
  include the median (horizontal band), 1st and 3rd quartiles (box
645
  extents), and $\pm$1.5$\times$IQR (whiskers); outliers not shown. Gray
646
  numbers above each whisker indicates how many thousands of pixels are
647
  included in the corresponding summary. Dashed red line indicates the
648
  median difference across all pixels south of 60\N.]{
649
    \includegraphics[width=\linewidth, trim=0 0 0 0.5in, clip=TRUE]{../dem/aster-srtm-bins.png}
650
    \label{aster-srtm-bins}
651
  }\\
652
  \subfloat[Pixel-wise plot of SRTM vs ASTER for all values in the 150
653
  latitudinal rows of overlap south of 60\N. Dashed blue line indicates
654
  the 1:1 diagonal, and the parallel red line is offset lower by the
655
  observed median difference between SRTM and ASTER (\Sexpr{delta.median}m).
656
  Inset histogram shows distribution of differences, excluding absolute
657
  differences >60.]{
658
    \includegraphics[width=\linewidth, trim=0 0 0 0.5in, clip=TRUE]{../dem/aster-srtm-scatter.png}
659
    \label{aster-srtm-scatter}
660
  }
661
  \label{aster-srtm}
662
\end{figure}
663

    
664
%
665
% Figures: Aspect rose diagrams
666
%
667
\begin{figure}[h!]
668
  \caption{Binned frequency distributions of aspect within two selected
669
    latitudinal strips: (a) within the SRTM-ASTER blend zone, and (b)
670
    south of the overlap zone. Aspect values here are based on the DEM
671
    produced via Gaussian weighted averaging, but similar patterns are
672
    evident using the other DEMs. Red spoke lines indicate the circular
673
    mean direction across all pixels at the associated latitude.}
674
  \centering
675
<<echo=FALSE,results=hide,fig=TRUE,height=5,width=7>>=
676
  library(circular)
677
  aspdir <- "/home/regetz/media/temp/terrain/aspect"
678
  a.bg <- raster(file.path(aspdir, "fused_300straddle_blendgau_a.tif"))
679
  par(mfrow=c(1,2), mar=c(0,0,4,0))
680
  y1 <- 200
681
  y2 <- 220
682
  cx <- circular(as.matrix(a.bg)[c(y1,y2),], units="degrees",
683
      rotation="clock", zero=pi/2)
684
  rose.diag(cx[1,], bins=8, axes=FALSE)
685
  mtext(paste("(a)", round(yFromRow(a.bg, y1), 3), "degrees"))
686
  axis.circular(at=circular(c(pi/2, pi, 3*pi/2, 2*pi)),
687
      labels=c("N", "W", "S", "E"))
688
  points(mean.circular(cx[1,], na.rm=TRUE), col="red")
689
  lines.circular(c(mean.circular(cx[1,], na.rm=TRUE), 0), c(0,-1),
690
      lwd=2, col="red")
691
  rose.diag(cx[2,], bins=8, axes=FALSE)
692
  mtext(paste("(b)", round(yFromRow(a.bg, y2), 3), "degrees"))
693
  axis.circular(at=circular(c(pi/2, pi, 3*pi/2, 2*pi)),
694
      labels=c("N", "W", "S", "E"))
695
  points(mean.circular(cx[2,], na.rm=TRUE), col="red")
696
  lines.circular(c(mean.circular(cx[2,], na.rm=TRUE), 0), c(0,-1),
697
      lwd=2, col="red")
698
@
699
  \label{rose-diag-aspect}
700
\end{figure}
701

    
702
%
703
% Figures: Flow direction rose diagrams
704
%
705
\begin{figure}[h!]
706
  \caption{Relative frequencies of D8 flow directions (indicated by
707
    relative heights of the blue spokes) within two selected
708
    latitudinal bands: (a) within the SRTM-ASTER blend zone, and (b)
709
    south of the overlap zone. Flow directions here are based on the DEM
710
    produced via Gaussian weighted averaging. Red spoke lines indicate
711
    the circular mean flow direction across all pixels at the associated
712
    latitude.}
713
  \centering
714
<<echo=FALSE,results=hide,fig=TRUE,height=5,width=7>>=
715
  library(circular)
716
  flowdir <- "/home/regetz/media/temp/terrain/flow"
717
  # create function to recode terraflow SFD values into degrees, with
718
  # 0=North and proceeding clockwise (this matches gdaldem's default
719
  # azimuth output for aspect calculation)
720
  recode <- function(r) {
721
      v <- values(r)
722
      v[v==0] <- NA
723
      v[v==1] <- 90  ## east
724
      v[v==2] <- 135
725
      v[v==4] <- 180  ## south
726
      v[v==8] <- 225
727
      v[v==16] <- 270  ## west
728
      v[v==32] <- 315
729
      v[v==64] <- 0  ## north
730
      v[v==128] <- 45
731
      r[] <- v
732
      return(r)
733
  }
734
  sfd.bg <- recode(raster(file.path(flowdir,
735
      "fused_300straddle_blendgau_sfd.tif")))
736
  par(mfrow=c(1,2), mar=c(0,0,4,0))
737
  y1 <- 200
738
  y2 <- 220
739
  cx <- circular(as.matrix(sfd.bg)[c(y1,y2),], units="degrees",
740
      rotation="clock", zero=pi/2)
741
  rose.diag(cx[1,], bins=1000, border="blue", ticks=FALSE, axes=FALSE)
742
  mtext(paste("(a)", round(yFromRow(sfd.bg, y1), 3), "degrees"))
743
  axis.circular(at=circular(c(pi/2, pi, 3*pi/2, 2*pi)),
744
      labels=c("N", "W", "S", "E"))
745
  points(mean.circular(cx[1,], na.rm=TRUE), col="red")
746
  lines.circular(c(mean.circular(cx[1,], na.rm=TRUE), 0), c(0,-1),
747
      lwd=2, col="red")
748
  rose.diag(cx[2,], bins=1000, border="blue", ticks=FALSE, axes=FALSE)
749
  mtext(paste("(b)", round(yFromRow(sfd.bg, y2), 3), "degrees"))
750
  axis.circular(at=circular(c(pi/2, pi, 3*pi/2, 2*pi)),
751
      labels=c("N", "W", "S", "E"))
752
  points(mean.circular(cx[2,], na.rm=TRUE), col="red")
753
  lines.circular(c(mean.circular(cx[2,], na.rm=TRUE), 0), c(0,-1),
754
      lwd=2, col="red")
755
@
756
  \label{rose-diag-flowdir}
757
\end{figure}
758

    
759
%
760
% Figures: Correlations and RMSEs
761
%
762
\begin{figure}
763
  \centering
764
  \caption{Elevation associations between original and fused layers}
765
  \subfloat[Elevation correlations]{
766
    \includegraphics[page=3, trim=1in 1in 1in 1in, width=\linewidth]{../dem/elevation-assessment.pdf}
767
    \label{corr-elevation}
768
  }\\
769
  \subfloat[Elevation RMSEs]{
770
    \includegraphics[page=2, trim=1in 1in 1in 1in, width=\linewidth]{../dem/elevation-assessment.pdf}
771
    \label{rmse-elevation}
772
  }
773
\end{figure}
774

    
775
\begin{figure}
776
  \centering
777
  \caption{Slope associations between original and fused layers}
778
  \subfloat[Slope correlations]{
779
    \includegraphics[page=3, trim=1in 1in 1in 1in, width=\linewidth]{../slope/slope-assessment.pdf}
780
    \label{corr-slope}
781
  }\\
782
  \subfloat[Slope RMSEs]{
783
    \includegraphics[page=2, trim=1in 1in 1in 1in, width=\linewidth]{../slope/slope-assessment.pdf}
784
    \label{rmse-slope}
785
  }
786
\end{figure}
787

    
788
\begin{figure}
789
  \centering
790
  \caption{Aspect associations between original and fused layers}
791
  \subfloat[Aspect circular correlations]{
792
    \includegraphics[page=3, trim=1in 1in 1in 1in, width=\linewidth]{../aspect/aspect-assessment.pdf}
793
    \label{corr-aspect}
794
  }\\
795
  \subfloat[Aspect RMSEs]{
796
    \includegraphics[page=2, trim=1in 1in 1in 1in, width=\linewidth]{../aspect/aspect-assessment.pdf}
797
    \label{rmse-aspect}
798
  }
799
\end{figure}
800

    
801
\begin{figure}
802
  \centering
803
  \caption{Flow direction associations between original and fused layers}
804
  \subfloat[Flow direction correlations]{
805
    \includegraphics[page=3, trim=1in 1in 1in 1in, width=\linewidth]{../flow/flowdir-assessment.pdf}
806
    \label{corr-flowdir}
807
  }\\
808
  \subfloat[Flow direction RMSEs]{
809
    \includegraphics[page=2, trim=1in 1in 1in 1in, width=\linewidth]{../flow/flowdir-assessment.pdf}
810
    \label{rmse-flowdir}
811
  }
812
\end{figure}
813

    
814

    
815
%-----------------------------------------------------------------------
816
\section{Code listings}
817
%-----------------------------------------------------------------------
818

    
819
\clearpage
820
\appendix
821

    
822
\lstinputlisting[language=bash, caption={GDAL commands for assembling
823
    and resampling SRTM and ASTER tiles into GeoTIFFs for use as inputs
824
    to the boundary correction routines described in this document.},
825
    label=code-gdalwarp]{../dem/boundary-assembly.sh}
826
\clearpage
827

    
828
\lstinputlisting[language=R, caption={R code implementing several
829
    SRTM-ASTER boundary corrections, including the Gaussian weighted
830
    average layer discussed in this document (see \texttt{OPTION 3}, as
831
    identified in code comments).},
832
    label=code-correct]{../dem/boundary-correction.R}
833
\clearpage
834

    
835
\lstinputlisting[language=bash, caption={GDAL commands for assembling
836
    boundary-corrected DEM components above and below 60\N, for each of
837
    several correction approaches implemented in Listing
838
    \ref{code-correct}. Note that multiresolution spline blending is
839
    treated separately (see Listing \ref{code-enblend}).},
840
    label=code-fuse]{../dem/boundary-fusion.sh}
841
\clearpage
842

    
843
\lstinputlisting[language=R, caption={R wrapper code for multiresolution
844
    spline of SRTM and ASTER.}, label=code-enblend]{../dem/enblend.R}
845
\clearpage
846

    
847
\lstinputlisting[language=bash, caption={GRASS code for computing
848
    flow directions using the various fused elevation rasters and their
849
    components DEMS as inputs.},
850
    label=code-flowdir]{../flow/flow-boundary.sh}
851

    
852
\end{document}
853

    
    (1-1/1)