SRTM数据主要是由美国太空总署(NASA)和国防部国家测绘局(NIMA)联合测量的,SRTM的全称是Shuttle Radar Topography Mission,即航天飞机雷达地形测绘使命。获取的雷达影像数据经过两年多的处理,制成了数字地形高程模型,该测量数据覆盖中国全境。SRTM数据每经纬度方格提供一个文件,精度有1 arc-second和3 arc-seconds两种,称作SRTM1和SRTM3,或者称作30M和90M数据,SRTM1的文件里面包含3601*3601个采样点的高度数据,SRTM3的文件里面包含1201*1201个采样点的高度数据。目前能够免费获取中国境内的RTM3文件,是90米的数据,每个90米的数据点是由 9个30米的数据点算术平均得来的。 SRTM数据下载的地址是:ftp://e0mss21u.ecs.nasa.gov/srtm/ 。我国境内的数据在Eurasia目录下,每经纬度方格一个文件,文件命名方法是X1X2X3X4.hgt.zip,X1是N或S表示南北,X2是下方纬度数,X3是E或W表示东西,X4是左方经度数。

我们在进行地学研究时有时会用到这种免费下载但分辨率适中的数据,可是SRTM数字高程模型的格式是hgt,我们怎么把其转换成ArcGIS支持的格式以供我们查看呢?美国地质调查局的工程师们用AML和地图代数语言混合编程写了一个小程序,专门用来将SRTM数据由hgt转换成GRID格式。把下列代码拷贝到记事本上,另存为srtmgrid.aml。

电脑上需要先安装ArcGIS workstation。

1.打开cmd窗口,用“cd /d 路径”的格式进入hgt数据所存放的位置;

2.然后输入"arc",在ArcGIS workstation arc环境下进行命令行操作;

3.输入“&r srtmgrid.aml”,表示运行我们刚才复制粘贴生成的AML程序。可以看到这个命令的用法。这里提示我们在运行该程序时要输入两个参数:输入文件名和输出文件;

4.明白了第3步以后,让我们正式开始执行该程序。输入“&r srtmgrid.aml N39E114.hgt N39E114”。注意该空格的地方要空格。该命令表示运行(run)srtmgrid.aml程序,输入文件为N39E114.hgt,输出文件为N39E114文件。由文件名我们也能看到:该文件的经纬度方格的范围是北纬39东经114.点击回车,即可执行。

5.再次输入quit,就从GRID环境退回到arc环境中,再次重复输入第4、5步的命令,只需将输入输出文件名改一下,就能将其他hgt文件转成GRID文件了,直到把所有的hgt文件全部转换完成为止。

6.输入“grid”,进入GRID 环境。我们要将第4、5步转换的GRID文件拼接(mosaic)成一个文件。输入“mosaic”,回车,就能看到mosaic命令的用法。我们要指定一个输出文件名,再将第4、5步生成的GRID文件名依次输进去,就行了。我们输入“bjdem = mosaic(N39E114,N39E115,N39E116,N39E117,N40E114,N40E115,N40E116,N40E117,N41E114,N41E115,N41E116,N41E117,N42E114,N42E115,N42E116,N42E117)”,回车,就把这些GRID文件全都拼接成一张图了。

7.有了第6步的成果,数据就算转换完成了,就可以用来进行自己的工作了。如果还想转成tiff格式或shp格式等,在ArcMap里面操作即可,也不难的。这里就不再赘述了。

srtmgrid.aml代码如下:

/*--------------------------------------------------------------------------
/* Program: SRTMGRID.AML
/* Purpose: Convert raw prelminary SRTM elevation data files
/* (.hgt extension) to ESRI GRID format. Many thanks to
/* Arthur Tarr, USGS, (atarr@usgs.gov) for figuring out how
/* to convert SRTM image files to ArcInfo GRID format.
/*
/* The georeferencing and grid-cell resolution
/* for the output grid is determined from the file
/* name and the size of the file.
/*--------------------------------------------------------------------------
/* Usage: &r srtmgrid <dat_file> <out_grid>
/*
/* Arguments:
/*
/* <dat_file> *.hgt binary file of elevation data
/* File must be named according to convention
/* on FTP site, e.g. N45W103.hgt
/*
/* <out_grid> Output grid name (must conform to ArcInfo naming
/* conventions)
/*--------------------------------------------------------------------------
/* Calls: *none*
/*--------------------------------------------------------------------------
/*
/* History:
/* 01/28/02 Curtis Price, USGS, cprice@usgs.gov
/* Original coding. Thanks to Arthur Tarr for figuring
/* out the integer data transformation in GRID.
/* 08/28/02 cprice
/* Updated to work with newer data
/* posted at ftp://edcsgs9.cr.usgs.gov/pub/data/srtm/GDPS
/* Also fixed header to match documentation
/* 11/19/03 cprice
/* Updated to work with global data (all dd quadrants)
/*
/* **********************************************************************
/*
/* Although this program has been used by the U.S. Geological
/* Survey, no warranty, expressed or implied, is made by the USGS as to
/* the accuracy and functioning of the program and related program
/* material nor shall the fact of distribution constitute any such
/* warranty, and no responsibility is assumed by the USGS in connection
/* therewith.
/*
/************************************************************************
&args datfile outgrid
&s os [extract 1 [show &os]]
&if [null %outgrid%] &then &do
&type Usage: &r srtmgrid <dat_file> <out_grid>
&type Example: &r srtmgrid N45W122.hgt srtm1g
&return
&end
&if %:program%_ eq ARC_ &then grid
&if %:program%_ ne GRID_ &then
&return This program must be run from ARC or GRID.
&if %os%_ nc Windows_NT &then &do
&s uxname %datfile%
&s datfile [locase %datfile%]
&if %datfile% ne %uxname% &then &sys mv %uxname% %datfile%
&end
&if ^ [exists %datfile% -file] &then
&return *** Data file %datfile% not found
&if [exists %outgrid% -dir] &then
&return *** %outgrid% exists. Cannot create a grid with that name.
/* extract image parameters from filename
&s fn [locase %datfile%]
&s xxll [unquote [translate %fn% ' ' nsew.hgt]]
&s xxlat [extract 1 %xxll%]
&s xxlon [extract 2 %xxll%]
&if [type %xxlat%] ge 0 &then &s badfn
&if [type %xxlon%] ge 0 &then &s badfn
&if [variable badfn] &then &do
&type Bad filename: %datfile%
&type This AML requires that the original SRTM filename be used.
&type For example: N44W103.hgt
&return
&end
/* determine lat long sign
&if [substr %fn% 1 1]_ eq s_ &then &s xxlat %xxlat% * -1
&if [substr %fn% 4 1]_ eq w_ &then &s xxlon %xxlon% * -1
/* calculate upper left corner of tile
&s xxlat [calc %xxlat% + 1]
/* determine arc-second resolution from filesize
&s tmpfil [scratchname -suf .dat]
&if %os% cn 'Windows_NT' &then &do
&sys dir %datfile% /l /-c > %tmpfil%
&s ch [open %tmpfil% st -r]
&s rec [read %ch% st]
&do &while %st% eq 0 and %rec% nc [locase %datfile%]
&s rec [read %ch% st]
&end
&s st [close %ch%]
&s xfn [unquote %rec%]
&s filesize = [extract [calc [token %xfn% -count] - 1] %xfn%]
&end
&else &do
&sys ls -l %datfile% > %tmpfil%
&s ch [open %tmpfil% st -r]
&s rec [read %ch% st]
&s st [close %ch%]
&s filesize [extract 5 [unquote %rec%]]
&end
&s st [delete %tmpfil%]
&if [type %filesize%] > 0 &then &return ** ERROR problem determining file size
&if %filesize% gt 5e6 &then &s arcsec 1
&else &s arcsec 3
/* calculate image size
&s ncells [calc 3600 / %arcsec% + 1]
&s cellsize [calc %arcsec% / 3600]
&type Reading %datfile% as %arcsec%-arc-second DEM ...
&type Copying image file ...
/* create bil file
&s tmpimg [scratchname -file -suf .bil]
&s st [copy %datfile% %tmpimg%]
/* write hdr file
&s tmphdr [before %tmpimg% .bil].hdr
&s ch [open %tmphdr% st -w]
&s st [write %ch% 'BYTEORDER M']
&s st [write %ch% 'LAYOUT BIL']
&s st [write %ch% [quote NROWS %ncells%]]
&s st [write %ch% [quote NCOLS %ncells%]]
&s st [write %ch% 'NBITS 16']
&s st [write %ch% [quote ULXMAP %xxlon%]]
&s st [write %ch% [quote ULYMAP %xxlat%]]
&s st [write %ch% [quote XDIM %cellsize%]]
&s st [write %ch% [quote YDIM %cellsize%]]
&s st [close %ch%]
&type Image parameters:
&type
&s ch [open %tmphdr% st -r]
&s rec [read %ch% st]
&do &while %st% eq 0
&type %rec%
&s rec [read %ch% st]
&end
&s st [close %ch%]
&type
/* read into data file into grid format
&s tmpgrid [scratchname -dir -suf g]
arc imagegrid %tmpimg% %tmpgrid%
/* convert image values as read to signed integer
/* (imagegrid does not support signed integers)
/* (Thanks to Arthur Tarr, USGS)
%outgrid% = con(~
%tmpgrid% gt 32768, %tmpgrid% - 65536, ~
%tmpgrid% lt 32768, %tmpgrid%)
/* Document projection for ArcInfo applications
arc projectdefine grid %outgrid%
projection geographic
units dd
zunits meters
datum wgs84
param
log %outgrid% add
Created from SRTM input file %datfile%
listoutput %tmphdr% init
&format 6
describe %outgrid%
&format 3
listoutput screen
&s ch [open %tmphdr% st -r]
&lv st ch
&do &until %st% ne 0
&type [read %ch% st]
&end
&s st [close %ch%]
kill %tmpgrid% all
&s st [delete %tmpimg% -file]
&s st [delete %tmphdr% -file]
&if %os% nc 'Windows_NT' &then
&if %datfile% ne %uxname% &then &sys mv %datfile% %uxname%
&return Processing completed.

SRTM DEM hgt格式转成GRID格式的问题解决相关推荐

  1. python使用openCV加载图像、并将BGR格式转换成HSV格式、定义HSV格式中需要分离颜色的掩码(掩模)区间(mask)、并使用mask信息进行颜色分离、BGR格式的图像转化为RGB、并可视化

    python使用openCV加载图像.并将BGR格式转换成HSV格式.定义HSV格式中需要分离颜色的掩码(掩模)区间(mask).并使用mask信息进行颜色分离.将BGR格式的图像转化为RGB.可视化 ...

  2. Win10系统如何将M4A音乐格式转换成MP3格式

    M4A和MP3一样也是一种音频格式,不一样的地方就是M4A的音质可能要比MP3好一些(因人而异).那么Win10系统如何将M4A音乐格式转换成MP3格式?其实我们可以利用音频格式转换器来转换M4A音乐 ...

  3. python datetime格式转换_分别用Excel和python进行日期格式转换成时间戳格式

    最近在处理一份驾驶行为方面的数据,其中要用到时间戳,因此就在此与大家一同分享学习一下. 1.什么是时间戳? 时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01 ...

  4. Excel中将时间格式转化成时间戳格式

    时间戳转成正常日期的公式: C1=(A1+8*3600)/86400+70*365+19 其中A1表示当时的1249488000时间戳数值 其中C1就是所需的日期格式,C1单元格属性改成日期格式就可以 ...

  5. vep文件如何转换mp4_如何将DVD的vob视频格式转换成mp4格式

    首先简述一下,VOB是DVD Video OBject的缩写,vob文件用来保存所有MPEG-2格式的音频和视频数据,这些数据不仅包含影片本身,而且还有供菜单和按钮用的画面以及多种字幕的子画面流.如何 ...

  6. 09: xmltodict 模块将xml格式转成json格式

    1.1 : xmltodict 模块将xml格式转成json格式 <?xml version="1.0"?> <!--#版本号--> <data> ...

  7. 如何把flv格式转成mp4格式?

    现在的网络视频发展的是越来越快,新的视频格式已越来越多,flv也是近几年由flash发展而来的视频格式.flv格式的视频体积虽小但加载速度还挺快,所以被逐渐的兴起认可.那flv格式的视频认可度越高,我 ...

  8. 如何将PDF格式转换成Excel格式?

    PDF和Excel这两种格式在我们的日常办公中经常需要用到,有时候PDF带有很多表格,但PDF格式的特殊性,不能进行类似Excel的操作,虽然有PDF编辑器可以直接编辑,但局限性还是很明显的,这时就需 ...

  9. python m4a转mp3_python脚本实现音频m4a格式转成MP3格式

    群里看到有人询问:谁会用python将微信音频文件后缀m4a格式转成mp3格式,毫不犹豫回了句:我会.然后就私下聊起来了 解决方法介绍如下: 工具:windows系统,python2.7,转换库ffm ...

最新文章

  1. Beaglebone Black教程BeagleBone Black安装最新系统映像
  2. autojs遍历当前页面所有控件_HTML5表单和表单控件的使用
  3. rapidminer员工离职分析_HR如何做好离职分析?
  4. springboot自动配置流程
  5. 架构漫谈 - 数据治理核心思路及解决方案探讨
  6. Graphviz:可视化工具Graphviz的简介、安装、使用方法、经典案例之详细攻略
  7. linux双机(多机)自动互备份方案
  8. Qt Marketplace
  9. win10无法装载iso文件_win 10如何装载和弹出ISO映像文件
  10. vb获取数组长度_如何实现数组的二分查找
  11. OWASP Top 10关键点记录
  12. oracle权限的分配
  13. python基础学习(四)if判断语句
  14. Python中的枚举类型及其用法
  15. uploadify php 重命名,关于uploadify上传插件获取文件名问题
  16. 华图教育计算机,计算机vf考试考什么
  17. 【安卓按键精灵自动取色(可用于比色,多点找色,找图实现)】
  18. 基于无人机的目标检测平台——数据中转(安卓App)
  19. Python zip, unzip, zip_longest的用法
  20. cad lisp 螺栓_如何用cad画螺丝

热门文章

  1. Linux安装MySQL8.0.29,并使用Navicat连接
  2. 人脸识别“SphereFace: Deep Hypersphere Embedding for Face Recognition”
  3. 2020-01-25
  4. Apache 流框架 Flink,Spark Streaming,Storm
  5. PFNet:Camouflaged Object Segmentation with Distraction Mining——论文简述
  6. 【微服务】SpringCloud微服务环境搭建
  7. 使用Java实现文档的下载(Excel,Word文档等)
  8. 小白如何开通微信公众号中的订阅号(服务号)以及认证账号
  9. 微信小程序开发.小程序入门(上)
  10. 西门子工业软件+Mendix,低代码让普通员工秒变技术员,你会被取代吗?