■ はじめに
* Javaで標高データを扱う * 今回扱うデータは、「SRTM」で、ビッグエンディアンの2バイト整数として格納されているビッグエンディアン については、以下の関連記事を参照のこと
https://blogs.yahoo.co.jp/dk521123/37795867.html
標高データ
標高 : elevation【1】 SRTM 1-1) SRTM-1 => 1秒メッシュ(約30m)の分割地形データ 1-2) SRTM-3 => 3秒メッシュ(約90m)の分割地形データ 【2】国土地理院「基盤地図情報(数値標高モデル)」 ※ ユーザ登録が必要 2-1) 5mメッシュ 2-2) 10mメッシュ
■ SRTM (Shuttle Radar Topography Mission; スペースシャトル地形データ)
* SRTM DEMフォーマット(.hgt) / バイナリデータ * ファイル名は、「北緯東経.hgt」で構成 => 例: N35E139.hgt = 北緯35度、東経139度 * 各標高値 : ビッグエンディアンの2バイト整数。単位は、メートル。
ダウンロード先
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/■ サンプル
* ビッグエンディアンをリトルエンディアンに変換する * 事前にデータをダウンロードしておくことhttps://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/
Main.java
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static void main(String[] args) { String filename = "C:\\N35E139.hgt\\N35E139.hgt"; int dataNumber = 1021; File file = new File(filename); try (InputStream inputStream = new FileInputStream(file);) { long length = file.length(); byte[] bytes = new byte[(int) length]; inputStream.read(bytes); int postion = 0; for (int row = 0; row < dataNumber; row++) { for (int col = 0; col < dataNumber; col++) { byte[] byteArrays = new byte[4]; int index = 0; byteArrays[index] = bytes[postion]; index++; postion++; byteArrays[index] = bytes[postion]; postion++; int height = ByteBuffer.wrap(byteArrays).order(ByteOrder.LITTLE_ENDIAN).getInt(); System.out.println("height = " + height); } } } catch (IOException ex) { ex.printStackTrace(); } } }
参考文献
標高データhttp://kamoland.com/wiki/wiki.cgi?SRTM3%A5%C7%A1%BC%A5%BF%A4%AB%A4%E9%C9%B8%B9%E2%A4%F2%C6%C9%A4%E0
http://www.gis-okinawa.jp/grid/SRTM3/
https://www.esrij.com/gis-guide/other-dataformat/elevation-data/
SRTM / JAXA
http://iss.jaxa.jp/shuttle/flight/sts99/mis_srtm.html
Java
https://www.programcreek.com/java-api-examples/index.php?source_dir=whitebox-geospatial-analysis-tools-master/WhiteboxGIS/resources/plugins/source_files/ImportSRTM.java
SRTM / JAXA
http://iss.jaxa.jp/shuttle/flight/sts99/mis_srtm.html
Java
https://www.programcreek.com/java-api-examples/index.php?source_dir=whitebox-geospatial-analysis-tools-master/WhiteboxGIS/resources/plugins/source_files/ImportSRTM.java