Project

General

Profile

« Previous | Next » 

Revision 6626e7db

Added by Jim Regetz over 13 years ago

  • ID 6626e7dbcf02d4f3455aaba796a6571882354dd8

added ASTER vs SRTM elevation comparision plots

View differences:

terrain/dem/dem-assessment.R
22 22
lats300 <- yFromRow(d.aster, 1:nrow(d.aster))
23 23
lats150 <- yFromRow(d.srtm, 1:nrow(d.srtm))
24 24

  
25
# initialize output pdf device driver
26
pdf("elevation-assessment.pdf", height=8, width=11.5)
27

  
28 25

  
29 26
#
30 27
# plot latitudinal profiles of mean elevation
31 28
#
32 29

  
30
# initialize output pdf device driver
31
pdf("elevation-assessment.pdf", height=8, width=11.5)
32

  
33 33
par(mfrow=c(2,2), omi=c(1,1,1,1))
34 34

  
35 35
ylim <- c(540, 575)
......
193 193
# close pdf device driver
194 194
dev.off()
195 195

  
196
#
197
# plot pattern of ASTER-SRTM deltas as a function of ASTER elevation
198
#
199

  
200
plotMeanDeltaByElev <- function(delta.vals, elev, ...) {
201
    mean.by.elev <- tapply(delta.vals, elev, mean)
202
    sd.by.elev <- tapply(delta.vals, elev, sd)
203
    n.by.elev <- tapply(delta.vals, elev, length)
204
    se.by.elev <- sd.by.elev/sqrt(n.by.elev)
205
    na.se.points <- mean.by.elev[is.na(se.by.elev)]
206
    se.by.elev[is.na(se.by.elev)] <- 0
207
    elev <- as.numeric(names(mean.by.elev))
208
    plot(elev, mean.by.elev, pch=16,
209
        xlim=c(0, max(elev)), ylim=c(min(mean.by.elev -
210
        se.by.elev), max(mean.by.elev + se.by.elev)), type="n", ...)
211
    segments(elev, mean.by.elev-se.by.elev,
212
        as.numeric(names(mean.by.elev)), mean.by.elev+se.by.elev,
213
        col="grey")
214
    points(elev, mean.by.elev, pch=".")
215
    points(as.numeric(names(na.se.points)), na.se.points, pch=4,
216
        col="red", cex=0.5)
217
}
218

  
219

  
220
d.aster.crop.vals <- values(crop(d.aster, extent(d.srtm)))
221
d.srtm.vals <- values(d.srtm)
222
delta.vals <- d.aster.crop.vals - d.srtm.vals
223
plotMeanDeltaByElev(delta.vals, d.aster.crop.vals,
224
    xlab="ASTER elevation (m)", ylab="ASTER-SRTM difference (m)")
225

  
226
plotDeltaBins <- function(delta.vals, elev, bin.min, bin.width, bin.max=1500,
227
    outline=FALSE, ...) {
228
    breaks <- seq(bin.min, bin.max, by=bin.width)
229
    midpts <- c(
230
        paste("<", bin.min, sep=""),
231
        head(breaks, -1) + bin.width/2,
232
        paste(">", bin.max, sep=""))
233
    elev <- cut(elev, breaks=c(0, breaks, Inf), labels=midpts)
234
    bp <- boxplot(delta.vals ~ elev, outline=outline, col="lightgray",
235
        frame=FALSE, ...)
236
    text(1:length(bp$n), bp$stats[5,], labels=round(bp$n/1000),
237
        pos=3, cex=0.5, offset=0.2, font=3, col="gray")
238
    #axis(3, at=seq_along(bp$n), labels=paste(round(bp$n/1000), "k", sep=""),
239
    #    cex.axis=0.7, tick=FALSE, font=3, line=-1)
240
    #mtext("n =", side=3, adj=0, font=3, cex=0.7)
241
    abline(h=median(delta.vals), col="red", lty=2)
242
    invisible(bp)
243
}
244

  
245
d.aster.crop.vals <- values(crop(d.aster, extent(d.srtm)))
246
d.srtm.vals <- values(d.srtm)
247
delta.vals <- d.aster.crop.vals - d.srtm.vals
248
#  d.aster.crop.vals <- d.aster.crop.vals[d.srtm.vals>0]
249
#  d.srtm.vals <- d.srtm.vals[d.srtm.vals>0]
250

  
251
png("aster-srtm-bins.png", height=5, width=8, units="in", res=300)
252
plotDeltaBins(delta.vals, d.aster.crop.vals, 150, 50, 1500, las=2,
253
    cex.axis=0.8, xlab="Midpoints of ASTER elevation bins (m)",
254
    ylab="(ASTER - SRTM)")
255
dev.off()
256

  
257
# plot scatter of aster vs srtm
258
png("aster-srtm-scatter.png", height=5, width=8, units="in", res=300)
259
plot(jitter(d.srtm.vals), jitter(d.aster.crop.vals), pch=".",
260
    xlab="SRTM elevation (m)", ylab="ASTER elevation (m)", cex=0.5)
261
abline(median(delta.vals), 1, col="red", cex=0.5)
262
abline(0, 1, col="blue", lty=2, cex=0.5)
263
dev.off()
264

  
265

  

Also available in: Unified diff