gpt4 book ai didi

file - 如何读取 NASA .hgt 二进制文件

转载 作者:行者123 更新时间:2023-12-03 11:29:17 25 4
gpt4 key购买 nike

如果您对二进制文件有所了解,我相信这真的很简单,但我是这方面的新手。

我如何从 NASA .hgt 文件中提取数据?以下是来自 www2.jpl.nasa.gov/srtm/faq.html 的描述:

The SRTM data files have names like "N34W119.hgt". What do the letters and numbers refer to, and what is ".hgt" format?

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. Thus, the "N34W119.hgt" file covers latitudes 34 to 35 North and longitudes 118-119 West (this file includes downtown Los Angeles, California). The filename extension ".hgt" simply stands for the word "height", meaning elevation. 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. 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). 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). For more information read the text file "SRTM_Topo.txt" at http://edcftp.cr.usgs.gov/pub/data/srtm/Readme.html



谢谢你的帮助!我将在 python 脚本中使用这些数据,所以如果你不能对任何其他语言使用任何特定于语言的技巧,那就太棒了。

最佳答案

一个经过测试的 numpy 示例:

import os
import math
import numpy

fn = 'DMV/N51E000.hgt'

siz = os.path.getsize(fn)
dim = int(math.sqrt(siz/2))

assert dim*dim*2 == siz, 'Invalid file size'

data = numpy.fromfile(fn, numpy.dtype('>i2'), dim*dim).reshape((dim, dim))

关于file - 如何读取 NASA .hgt 二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/357415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com