Revision 933632ec
Added by Jim Regetz over 13 years ago
- ID 933632ec382cee00cf65d37141d3a6304aa61385
terrain/dem/enblend.R | ||
---|---|---|
1 | 1 |
# Code to produce enblended DEM (i.e., using multiresolution splines as |
2 |
# described by Burt & Adelson 1983) in the 60N boundary region. |
|
2 |
# 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. |
|
3 | 7 |
# |
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). |
|
8 |
# 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). |
|
12 | 11 |
# |
13 | 12 |
# Jim Regetz |
14 | 13 |
# NCEAS |
... | ... | |
42 | 41 |
writeRaster(brick(srtm, alpha), file="srtm-enblend.tif", |
43 | 42 |
options="ALPHA=YES") |
44 | 43 |
|
45 |
|
|
46 |
# DO ENBLEND HERE |
|
44 |
# run 'enblend' |
|
47 | 45 |
system(paste("enblend --verbose=6 -o enblend.tif", |
48 | 46 |
"aster-enblend.tif srtm-enblend.tif")) |
49 | 47 |
|
50 | 48 |
# post-process enblended DEM |
51 | 49 |
e <- raster("enblend.tif") |
52 | 50 |
e2 <- aster |
53 |
# round to nearest integer |
|
51 |
# round to nearest integer, and write out the result as a geotiff
|
|
54 | 52 |
e2[] <- as.integer(round(values(e), 0)) |
55 | 53 |
writeRaster(e2, file=file.path(demdir, "fused_300straddle_enblend.tif"), |
56 | 54 |
options="COMPRESS=NONE", datatype="INT2S") |
Also available in: Unified diff
minor cleanup of code comments