Created
August 26, 2020 21:25
-
-
Save zdila/9dc0ffa6712d84470b2846d061b8da7d to your computer and use it in GitHub Desktop.
Merge two HGT files taking nodata (-32768) into account.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const base = Deno.args[0]; | |
const data1 = await Deno.readFile(`in1/${base}.HGT`); | |
const data2 = await Deno.readFile(`in2/${base}.HGT`); | |
const buf1 = new DataView(data1.buffer); | |
const buf2 = new DataView(data2.buffer); | |
for (let i = 0; i < buf2.byteLength - 1; i += 2) { | |
const val = buf2.getInt16(i, false); | |
if (val !== -32768) { | |
buf1.setInt16(i, val, false); | |
} | |
} | |
await Deno.writeFile(`out/${base}.HGT`, data1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment