基金项目:云南省社会发展科技计划——社会事业发展专项“城市地震安全关键技术应用与示范研究”(2007CA002)和云南省地震局青年基金(200805)联合资助.
(Earthquake Adiministribution of Yunnan province,Kunming 650224,Yunnan,China)
software GMT,grid data,vector data,strong ground motion stations,distribution map
备注
基金项目:云南省社会发展科技计划——社会事业发展专项“城市地震安全关键技术应用与示范研究”(2007CA002)和云南省地震局青年基金(200805)联合资助.
通过研究云南省强震动台站分布图的绘制,分析了GMT的软件组成、数据结构,论述了地形栅格数据和点状矢量数据在GMT软件中的绘制方法。结果 表明,在GMT软件中绘制地图,对于栅格数据,最有效的数据格式为NetcDF栅格文件; 而对于矢量数据,则应采用ASCⅡ码表。
GMT is the indispensable map plotting third-party software package of software ShakeMap,which drawing strong ground motion map.Grasping GMT and applying the software to draw local maps is the necessary condition,of which the software ShakeMap can play a role in Yunnan strong ground motion monitoring and researching.By researching the ploting of Yunnan Province strong ground motion stations distribution map,the article analyzed GMT's components and data structure,discussed the method of drawing terrain grid data and point vector data with GMT.
引言
GMT(Generic Mapping Tools)是一个通用地图制图工具软件,由哥伦比亚大学的两位毕业生Paul Wessel和Walter H.F.Smith于1987 年开发(吴秋瑾,2006),发展至今已在大气、海洋、地震等研究领域得到较为广泛的应用,它也是震动图软件ShakeMap必不可少的第三方软件包之一。ShakeMap是由美国地质调查局开发完成并免费提供应用的震动图软件,它具有功能强大、自动化程度高、即时响应等特点,是国际上较为先进和通用的地震专业软件。ShakeMap对强震动研究、烈度速报和地震应急等工作有着重要意义,但该软件组成复杂、数据结构特殊,安装难度较大,运行时需要调用许多第三方软件包,而GMT正是支撑其地图绘制功能的第三方软件包。因此研究GMT软件的数据结构并应用GMT绘制本土数字地图,能使我们在强震研究中较好地应用ShakeMap软件。
“十五”期间建成的云南数字强震动观测台网是国家重大建设项目——中国数字地震观测网络的重要组成部分(崔建文等,2006),而《云南省强震动台分布图》是该台网所需的基础数字地图。该图对强震工作人员直观地了解强震台站的分布情况,在大震发生后能有的放矢地快速回收强震动数据、判断灾情有较大帮助。由于云南省强震动台站分布图包含了栅格和矢量两大类数据,因此应用GMT软件来绘制该图,既有实际的需求,也可通过绘图实践较为全面地研究GMT软件的数据结构和使用方法,并发现GMT软件在数据格式方面需要进一步研究的问题。
1 GMT软件概况
1.1 GMT软件的组成GMT是全命令行软件,需要用户录入命令及其指定的输入输出数据和各种配置参数(如经度、纬度、颜色配置等)来进行操作。GMT虽然操作相对繁琐,但执行效率很高,而且图形文件输出的主要格式为PostScript文件,这种格式可提供高质量、跨平台的图形打印,这也是GMT得以广泛应用的原因。
(1)输入:包括表文件(矢量数据)、栅格数据和调色板文件;(2)工作控制:GMT的命令行程序、默认配置和支持数据。其中命令行程序有60多条,包括绘制不同类型地图、数据格式转换、调色板文件生成、地图运算等功能;(3)输出:包括PostScript图形文件、表文件(矢量数据)、栅格数据、统计信息、警告和错误提示等。
1.2 GMT软件的安装平台GMT软件最早是在UNIX 系统上开发的,因此主要在UNIX系列的操作系统平台上运行,如Linux、FreeBSD、AIX等。经过对比测试,我们将云南数字强震动观测台网数据中心使用的GMT软件安装在FreeBSD操作系统的服务器上。
FreeBSD系统是UNIX系列的一个重要分支,能够在Intel x86 family、DEC Alpha、Sun UltraSPARC以及AMD64等多种类型的处理器平台上运行(张纪青,2002),具有很强的兼容性和稳定性。实际的安装和使用结果表明,GMT软件在FreeBSD系统上运行是可靠和稳定的。
2 GMT软件使用的数据格式
2.1 栅格数据(1)NetCDF栅格文件
默认情况下,GMT软件将二维的栅格数据存储为适应COARDS标准的NetCDF文件。NetCDF文件全称为Network Common Data Format(网络通用数据格式),由美国大气研究大学协会(UCAR)在Unidata程序中开发(David,1996)。这是一种通用的二进制数据存取方式,目的是方便程序开发人员利用C、Fortran、C++、Perl等不同的程序语言读写数据文件。由于它本身具有自我说明能力,并且可以跨越平台而不受机器的限制,因此从开始时仅用于存储气象科学数据的格式,发展成为现在许多数据采集软件的标准输出数据格式。而COARDS则是一个许多研究机构用于发布海洋和大气研究的栅格化数据的协议(Wessel,Smith,2008),这个协议使得GMT软件既可以读取其它专业软件所提供的NetCDF栅格数据文件,同时也使其创建的NetCDF栅格数据文件能够被其它领域的专业软件读取。
一个NetCDF文件由变量、维和属性3个部分组成(Laomai,2007)。变量是每个X/Y(经纬度)坐标点对应的无量纲的数值,它的物理量要由属性来说明,可以是气压、温度或高程等,它们随自变量而变化。而自变量就是维,可以是时间、高程或经纬度坐标,一个NetCDF文件可以包含多个维,每一维变量都有包括全名、度量单位及意义等其自我说明的数据。对于本研究所使用的栅格结构的数字高程模型数据,每个栅格的高程值就是其变量,经度和纬度就是它的两个维(自变量),高程就是其属性。
(2)其它栅格文件
除了默认的NetCDF格式外,GMT也支持早期版本中常用的老式二进制文件(即本地二进制栅格文件),以便新版本的软件能够处理早期生成和编辑的数据。这种文件类似NetCDF文件,也带有一个数据头文件,里面包含了定义文件内容的属性,可以用GMT程序对其进行部分编辑(Wessel,Smith,2008)。与本地二进制栅格文件结构类似的数据还有Sun公司开发的栅格文件,GMT也能够读写和处理这种数据。但由于这些数据格式特殊、适用面窄,一般很少使用。
2.2 矢量数据GMT软件的矢量数据为表文件,表文件的格式要求是有n行、m列,行列一一对应的二维表。每一行代表一个点要素记录,每一列则为记录的属性字段(坐标、名称、编号、高程等)。常用的表文件有ASCII码表、二进制表和NetCDF表。
(1)ASCII码表
ASCII码表由于是文本文件,很多地理数据都比较容易转换而且编辑也比较方便,因此是绘制点、线、面等矢量数据最常用的表文件。其内容只要符合GMT软件的格式要求即可,其中每一个记录的字段必须被空格、制表符或逗号隔开,字段可以是整型或浮点型的数字,或是表示地理坐标的字符串。另外,对于线状和面状地理要素,由于多行记录才对应一个地理要素,因此需要在每个地理要素的起始数据记录前加一个分段数据头文件作为唯一标识符,形成分段数据文件。
(2)本地二进制表
本地二进制表是GMT软件自身支持的特殊格式的二进制文件,可移植性差,其它软件不能识别,主要用于执行栅格化和预处理任务。本文研究没有采用。
(3)NetCDF表
从4.3.0版本以后,GMT软件开始支持NetCDF列表文件。NetCDF列表文件包含元数据,读起来不如读取二进制表复杂,甚至比ASCII码表还简单。但由于目前GMT只能读取NetCDF列表文件,还不能输出(Wessel,Smith,2008),因此本研究中没有采取这种格式来绘制矢量数据。
3 云南省强震动台站分布图的绘制
3.1 栅格数据地形图的绘制(1)栅格数据的格式转换
目前ArcGIS软件是应用比较广泛的地理信息系统软件,通常使用的基础地理数据多数都是ArcGIS软件格式。而ESRI GRID是ArcGIS软件的标准栅格数据格式(党安荣等,2003),所以本研究采用的原始数据为ESRI GRID格式的云南省数字高程模型(图1)。
在GMT软件中,用命令行方式绘制地图,每个命令根据用户需要,调用若干参数。主要使用的命令有3个:(1)grdgradient命令,该命令生成地形坡度阴影图(即地貌晕渲图),使地形图具有三维立体效果;(2)makecpt命令,该命令创建一个调色板表文件,按海拔高度为地形图着色;(3)grdview命令,该命令首先通过一系列用户指定的参数绘制基础图框,然后调用grdgradient命令生成的地形坡度阴影图和makecpt命令生成的调色板表文件进行叠加和着色,从而生成具有三维立体效果的分层设色地形图(图3)。
3.2 强震动台站分布点的绘制(1)矢量数据的格式转换
云南省强震动台站分布点的原始数据为点状的ArcGIS软件shape文件,是典型的矢量数据。将台站分布点的shape文件导出为没有文件头的ASCII码表,由于只涉及点状数据,因此不需使用分段数据。每行记录的各个字段用空格分隔开,根据GMT软件的要求,第一列字段为经度坐标,第二列字段为纬度坐标(Wessel,Smith,2008)。台站分布点的ASCII码文本文件如图4。
图4 云南省强震动台站分布点的ASCII码表
Fig.4 ASCII table of Yunnan Province strong motion stations distribution points在GMT软件中,使用psxyz命令来绘制点状矢量数据,通过调用不同参数来设置所绘地图数学基础和地图要素的各种属性。
本研究调用参数“-Jm4i”指定地图投影为墨卡托投影,比例尺为4英寸/经纬度; 参数“-St0.5”将台站分布点的形状设置为三角形,并指定其外接圆的直径大小为0.5英寸; 参数“-G250/0/0”指定符号的颜色为红色。用GMT软件绘制的云南省强震动台站分布点参看图5。
3.3 云南省强震动台分布图的绘制和显示把云南省强震动台分布点的矢量数据叠加绘制到先前生成的云南省地形图上,就完成了云南省强震动台分布图的绘制。最终生成的地图为PostScript(PS)格式文件,它是可供打印高质量图形的文件,但需要 GSview等软件才能显示。最终生成的云南省强震动台分布如图6,红色三角形代表强震动台站,地形图的海拔高程由蓝到红逐渐升高。
可以将PS(PostScript)文件转换为其它格式,如PhotoShop软件的png图像格式,或再转换为GIF、JPG等格式。
4 结论和问题
通过应用GMT软件实际绘图,我们初步掌握了GMT软件的组成、安装平台、数据结构和基本使用方法。实现了将ArcGIS软件格式的栅格数据和点状矢量数据转换为GMT软件所支持格式,应用GMT软件完成了云南省强震动台分布图的绘制。
研究表明,在GMT软件中绘制地图,对于栅格数据,最有效的数据格式为NetCDF栅格文件; 而对矢量数据,则应该采用ASCII码表。
目前,云南省强震动台分布点矢量数据已经能够应用于ShakeMap软件,作为绘制烈度分布图的地图要素,但是栅格地形数据还不能和ShakeMap软件绘制的其它地图要素相匹配。因此,如何将本土栅格数据通过GMT应用到ShakeMap软件中是一个需要深入研究的问题。
- 崔建文,高东,李世成,等.2006.新的云南数字强震动观测网络[J].地震研究,29(增刊):453-458.
- 党安荣,贾海峰,易善帧,等.2003.ArcGIS 8 Desktop 地理信息系统应用指南[M].北京:清华大学出版社.
- 柯佳伶.2006.GMT的使用[EB/OL].http://www.fg.tp.edu.tw/~vision/docs/satellite06/GMT3.dbf.
- 吴秋瑾.2006.GMT概念及操作[EB/OL].http://www.fg.tp.edu.tw/~vision/docs/satellite06/GMT1.dbf.
- 张纪青.2002.FreeBSD使用手册[EB/OL].http://man.ddvip.com/os/freebsdsyzsc/index.html.
- David F.1996.The NetCDF Users' Guide[EB/OL].http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.
- Laomai.2007.netcdf入门[EB/OL].http://blog.csdn.net/laomai/archive/2007/08/13/1740747.aspx.
- Paul Wessel,Walter H F Smith.2008.GMT_Docs[EB/OL].http://gmt.soest.hawaii.edu.