Project

General

Profile

Download (1.69 KB) Statistics
| Branch: | Revision:
1 f12b574f Jim Regetz
# Code to produce enblended DEM (i.e., using multiresolution splines as
2
# described by Burt & Adelson 1983) in the 60N boundary region.
3
#
4
# This code makes a system call to run 'enblend' (v. 4.0) on the
5
# prepared ASTER and SRTM layers, and then post-processes the resulting
6
# image to yield a single band geotiff with datatype of 16bit signed
7
# integer, matching the input data.
8
#
9
# Somewhat arbitrarily, in the code below I prep the input data such
10
# that the area of overlap is the first 75 rows below 60N (i.e., a zone
11
# extending ~6.75km south of the boundary).
12
#
13
# Jim Regetz
14
# NCEAS
15
# Created on 29-Jun-2011
16
17
library(raster)
18
19
demdir <- "/home/regetz/media/temp/terrain/dem"
20
21
# read in aster data
22
aster <- raster(file.path(demdir, "aster_300straddle.tif"))
23
# create alpha layer for aster
24
alpha <- aster
25
alpha[] <- 0
26
alpha[1:225, ] <- 1
27
# write enblend-ready tif out to disk
28
writeRaster(brick(aster, alpha), file="aster-enblend.tif",
29
    options="ALPHA=YES")
30
31
# read in srtm
32
srtm.lower <- raster("../srtm_150below.tif")
33
# expand to match full image (i.e., same extent as aster), holding srtm
34
# data below 60N and nothing above
35
srtm <- aster
36
srtm[] <- NA
37
srtm[151:300, ] <- values(srtm.lower)
38
# create alpha layer for srtm
39
alpha <- srtm
40
alpha[] <- 0
41
alpha[151:300, ] <- 1
42
writeRaster(brick(srtm, alpha), file="srtm-enblend.tif",
43
    options="ALPHA=YES")
44
45
46
# DO ENBLEND HERE
47
system(paste("enblend --verbose=6 -o enblend.tif",
48
    "aster-enblend.tif srtm-enblend.tif"))
49
50
# post-process enblended DEM
51
e <- raster("enblend.tif")
52
e2 <- aster
53
# round to nearest integer
54
e2[] <- as.integer(round(values(e2), 0))
55
writeRaster(e2, file=file.path(demdir, "fused_300straddle_enblend.tif"),
56
    options="COMPRESS=NONE", datatype="INT2S")