简体   繁体   English

NASA中的NASA二进制文件

[英]Nasa binary files in Java

I have file with binary data. 我有二进制数据文件。 This is specification: 这是规范:

The SRTM data files have names like "N34W119.hgt". SRTM数据文件的名称类似“ N34W119.hgt”。 What do the letters and numbers refer to, and what is ".hgt" format? 字母和数字指的是什么,“。hgt”格式是什么?

Each data file covers a one-degree-of-latitude by one-degree-of-longitude block of Earth's surface. 每个数据文件覆盖地球表面的一个纬度乘一个经度块。 The first seven characters indicate the southwest corner of the block, with N, S, E, and W referring to north, south, east, and west. 前七个字符指示块的西南角,N,S,E和W分别指北,南,东和西。 Thus, the "N34W119.hgt" file covers latitudes 34 to 35 North and longitudes 118-119 West (this file includes downtown Los Angeles, California). 因此,“ N34W119.hgt”文件涵盖北纬34至35和西经118-119(此文件包括加利福尼亚州洛杉矶市中心)。 The filename extension ".hgt" simply stands for the word "height", meaning elevation. 文件扩展名“ .hgt”仅代表单词“ height”,表示海拔。 It is NOT a format type. 它不是格式类型。 These files are in "raw" format (no headers and not compressed), 16-bit signed integers, elevation measured in meters above sea level, in a "geographic" (latitude and longitude array) projection, with data voids indicated by -32768. 这些文件为“原始”格式(无标头且未压缩),16位带符号整数,以“地理”(纬度和经度数组)投影形式显示的海拔高度,以海平面以上的米为单位,数据空白由-32768表示。 International 3-arc-second files have 1201 columns and 1201 rows of data, with a total filesize of 2,884,802 bytes ( = 1201 x 1201 x 2). 国际3弧秒文件具有1201列和1201行数据,总文件大小为2884802字节(= 1201 x 1201 x 2)。 United States 1-arc-second files have 3601 columns and 3601 rows of data, with a total filesize of 25,934,402 bytes ( = 3601 x 3601 x 2). 美国一秒秒文件具有3601列和3601行数据,总文件大小为25,934,402字节(= 3601 x 3601 x 2)。 For more information read the text file "SRTM_Topo.txt" at http://edcftp.cr.usgs.gov/pub/data/srtm/Readme.html 有关更多信息,请阅读http://edcftp.cr.usgs.gov/pub/data/srtm/Readme.html上的文本文件“ SRTM_Topo.txt”。

Anyone can help me how I can read this file in java? 任何人都可以帮助我如何在Java中读取此文件? It is possible to read this file to array, because I need to do some operations on elements from this file? 可以将此文件读取为数组,因为我需要对该文件中的元素执行一些操作?

I would read the entire file into a ShortBuffer (so you choose the endianess) 我会将整个文件读到ShortBuffer中(以便您选择字节序)

FileChannel fc = new FileInputStream(file).getChannel();
ByteBuffer bb = ByteBuffer.allocateDirect((int) fc.size());
while (bb.remaining() > 0) fc.read(bb);
fc.close();
bb.flip();
// choose the right endianness
ShortBuffer sb = bb.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM