Project

General

Profile

« Previous | Next » 

Revision 7210104d

Added by Jim Regetz over 13 years ago

  • ID 7210104d0ddbf40cd0fe0ff5aa2c63b4fa42dfda

added slope boundary descrepancy plotting code

View differences:

terrain/dem/dem-fusion.txt
215 215
plot(crop(blendgau, window), main="south gaussian blend (hillshade)")
216 216
dev.off()
217 217

  
218

  
219
#=======================================================================
220
# R -- assess boundary artifacts with respect to slope
221
#=======================================================================
222

  
223
s.aster <- raster("aster_300straddle_s.tif")
224
s.srtm <- raster("srtm_150below_s.tif")
225
s.uncor <- raster("fused_300straddle_s.tif")
226
s.eramp <- raster("fused_300straddle_rampexp_s.tif")
227
s.bg <- raster("fused_300straddle_blendgau_s.tif")
228
s.can <- raster("cdem_300straddle_s.tif")
229

  
230

  
231
rmse <- function(r1, r2) {
232
    sqrt(rowMeans(as.matrix((r1 - r2)^2), na.rm=TRUE))
233
}
234

  
235
pdf("slope-rmse.pdf", height=8, width=11.5)
236
par(mfrow=c(2,3), omi=c(1,1,1,1))
237
lats300 <- yFromRow(s.aster, 1:nrow(s.aster))
238
lats150 <- yFromRow(s.srtm, 1:nrow(s.srtm))
239
# Latitudinal RMSE profiles with respect to ASTER
240
plot(lats300, rmse(s.uncor, s.aster), type="l", xlab="Latitude",
241
    ylab="RMSE", ylim=c(0, 5))
242
lines(lats150, rmse(crop(s.uncor, extent(s.srtm)), s.srtm), col="blue")
243
legend("topright", legend=c("ASTER", "SRTM"), col=c("black", "blue"),
244
    lty=c(1, 1), bty="n")
245
text(min(lats300), 4.5, pos=4, font=3, labels="uncorrected")
246
abline(v=60, col="red", lty=2)
247
mtext("Slope discrepancies with respect to separate ASTER/SRTM components",
248
    adj=0, line=2, font=2)
249
plot(lats300, rmse(s.eramp, s.aster), type="l", xlab="Latitude",
250
    ylab="RMSE", ylim=c(0, 5))
251
lines(lats150, rmse(crop(s.eramp, extent(s.srtm)), s.srtm), col="blue")
252
legend("topright", legend=c("ASTER", "SRTM"), col=c("black", "blue"),
253
    lty=c(1, 1), bty="n")
254
text(min(lats300), 4.5, pos=4, font=3, labels="exponential ramp")
255
abline(v=60, col="red", lty=2)
256
plot(lats300, rmse(s.bg, s.aster), type="l", xlab="Latitude",
257
    ylab="RMSE", ylim=c(0, 5))
258
lines(lats150, rmse(crop(s.bg, extent(s.srtm)), s.srtm), col="blue")
259
legend("topright", legend=c("ASTER", "SRTM"), col=c("black", "blue"),
260
    lty=c(1, 1), bty="n")
261
text(min(lats300), 4.5, pos=4, font=3, labels="gaussian blend")
262
abline(v=60, col="red", lty=2)
263

  
264
# Latitudinal RMSE profiles with respect to CDEM
265
plot(lats300, rmse(s.uncor, s.can), type="l", xlab="Latitude",
266
    ylab="RMSE", ylim=c(0, 5))
267
text(min(lats300), 4.5, pos=4, font=3, labels="uncorrected")
268
abline(v=60, col="red", lty=2)
269
mtext("Slope discrepancies with respect to Canada DEM",
270
    adj=0, line=2, font=2)
271
plot(lats300, rmse(s.eramp, s.can), type="l", xlab="Latitude",
272
    ylab="RMSE", ylim=c(0, 5))
273
text(min(lats300), 4.5, pos=4, font=3, labels="exponential ramp")
274
abline(v=60, col="red", lty=2)
275
plot(lats300, rmse(s.bg, s.can), type="l", xlab="Latitude",
276
    ylab="RMSE", ylim=c(0, 5))
277
text(min(lats300), 4.5, pos=4, font=3, labels="gaussian blend")
278
abline(v=60, col="red", lty=2)
279
dev.off()
280

  
281

  
282
####
283
corByLat <- function(r1, r2, rows) {
284
    if (missing(rows)) {
285
        rows <- 1:nrow(r1)
286
    }
287
    m1 <- as.matrix(r1)
288
    m2 <- as.matrix(r2)
289
    sapply(rows, function(row) cor(m1[row,], m2[row,],
290
        use="pairwise.complete.obs"))
291
}
292

  
293
pdf("slope-corr.pdf", height=8, width=11.5)
294
par(mfrow=c(2,3), omi=c(1,1,1,1))
295
lats300 <- yFromRow(s.aster, 1:nrow(s.aster))
296
lats150 <- yFromRow(s.srtm, 1:nrow(s.srtm))
297
ylim <- c(0.65, 1)
298
# Latitudinal RMSE profiles with respect to ASTER
299
plot(lats300, corByLat(s.uncor, s.aster), type="l", xlab="Latitude",
300
    ylab="Correlation", ylim=ylim)
301
lines(lats150, corByLat(crop(s.uncor, extent(s.srtm)), s.srtm), col="blue")
302
legend("bottomright", legend=c("ASTER", "SRTM"), col=c("black", "blue"),
303
    lty=c(1, 1), bty="n")
304
text(min(lats300), min(ylim), pos=4, font=3, labels="uncorrected")
305
abline(v=60, col="red", lty=2)
306
mtext("Slope correlations with separate ASTER/SRTM components",
307
    adj=0, line=2, font=2)
308
plot(lats300, corByLat(s.eramp, s.aster), type="l", xlab="Latitude",
309
    ylab="Correlation", ylim=ylim)
310
lines(lats150, corByLat(crop(s.eramp, extent(s.srtm)), s.srtm), col="blue")
311
legend("bottomright", legend=c("ASTER", "SRTM"), col=c("black", "blue"),
312
    lty=c(1, 1), bty="n")
313
text(min(lats300), min(ylim), pos=4, font=3, labels="exponential ramp")
314
abline(v=60, col="red", lty=2)
315
plot(lats300, corByLat(s.bg, s.aster), type="l", xlab="Latitude",
316
    ylab="Correlation", ylim=ylim)
317
lines(lats150, corByLat(crop(s.bg, extent(s.srtm)), s.srtm), col="blue")
318
legend("bottomright", legend=c("ASTER", "SRTM"), col=c("black", "blue"),
319
    lty=c(1, 1), bty="n")
320
text(min(lats300), min(ylim), pos=4, font=3, labels="gaussian blend")
321
abline(v=60, col="red", lty=2)
322

  
323
# Latitudinal correlation profiles with respect to CDEM
324
plot(lats300, corByLat(s.uncor, s.can), type="l", xlab="Latitude",
325
    ylab="Correlation", ylim=ylim)
326
text(min(lats300), min(ylim), pos=4, font=3, labels="uncorrected")
327
abline(v=60, col="red", lty=2)
328
mtext("Slope correlations with Canada DEM",
329
    adj=0, line=2, font=2)
330
plot(lats300, corByLat(s.eramp, s.can), type="l", xlab="Latitude",
331
    ylab="Correlation", ylim=ylim)
332
text(min(lats300), min(ylim), pos=4, font=3, labels="exponential ramp")
333
abline(v=60, col="red", lty=2)
334
plot(lats300, corByLat(s.bg, s.can), type="l", xlab="Latitude",
335
    ylab="Correlation", ylim=ylim)
336
text(min(lats300), min(ylim), pos=4, font=3, labels="gaussian blend")
337
abline(v=60, col="red", lty=2)
338
dev.off()
339

  

Also available in: Unified diff