如何在 R 中读取 .HGT 文件
How to read .HGT files in R
我正在尝试将存储在 .HGT 文件中的 NASA 海拔数据读取到 R 中。我检查了 rgdal
库,但显然它不读取此类文件。
ps。 Stack Overflow 社区在 Python and C++ 中展示了如何读取此类文件,但我一直在寻找纯 R 解决方案。
有关 .HGT 文件中地形数据的更多信息:
2014 年,NASA 航天飞机雷达地形测绘任务 (SRTM) 生成的地形数据在全球发布。美国以外地区的 SRTM 数据分辨率为 1 角秒,或大约 30 米(98 英尺)。您可以阅读更多信息here and download the data here。
目前,可以使用世界这些地区的数据:
这是来自 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
使用 raster
包答案很简单(感谢@Pascal 和@hrbrmstr 的评论)。 rgdal
包也必须安装。
# Load libraries
library(raster)
library(rgdal)
# read file
elevation <- raster("S23W044.hgt")
# view image
image(elevation)
我正在尝试将存储在 .HGT 文件中的 NASA 海拔数据读取到 R 中。我检查了 rgdal
库,但显然它不读取此类文件。
ps。 Stack Overflow 社区在 Python and C++ 中展示了如何读取此类文件,但我一直在寻找纯 R 解决方案。
有关 .HGT 文件中地形数据的更多信息:
2014 年,NASA 航天飞机雷达地形测绘任务 (SRTM) 生成的地形数据在全球发布。美国以外地区的 SRTM 数据分辨率为 1 角秒,或大约 30 米(98 英尺)。您可以阅读更多信息here and download the data here。
目前,可以使用世界这些地区的数据:
这是来自 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
使用 raster
包答案很简单(感谢@Pascal 和@hrbrmstr 的评论)。 rgdal
包也必须安装。
# Load libraries
library(raster)
library(rgdal)
# read file
elevation <- raster("S23W044.hgt")
# view image
image(elevation)