Project

General

Profile

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