当前位置:文档之家› SHP文件格式的研究与应用

SHP文件格式的研究与应用

第31卷第6期2006年11月测绘科学Sc i ence o f Survey ing and M app i ngV o l 131N o 16N ov 1作者简介:刘锋(1980O ),男,中国测绘科学研究院摄影测量与遥感专业研究生,主要从事RS 和G IS 开发与应用研究。

E O m a i:l li ufeng1980421@1261com 收稿日期:2006O 01O 05基金项目:国土资源部土地资源遥感监测信息获取与处理软件开发(2003AA131010)S HP 文件格式的研究与应用刘锋,张继贤,李海涛(中国测绘科学研究院,北京 100039)【摘 要】在全国第二次土地详查中,土地利用基础图件大部分是以S H P 文件格式存储的,因此在对土地利用基础图件进行更新的过程中,首要的问题是对SHP 文件的访问。

本文以解决这一问题为目标,以S HP 文件中常用的多边形元素为例,对S H P 文件中二进制格式的元素表示方法加以阐述,并以程序实现的方式对资料进行了访问,最终在项目中得到了充分的应用。

【关键词】土地利用基础图件;S H P 文件格式;多边形元素【中图分类号】TP311 【文献标识码】A 【文章编号】1009O 2307(2006)06O 0116O 021 引 言S H P 文件格式是美国ESR I 公司生产的A rcV iew 和A rc G IS 软件的专用资料格式,它将地理空间资料以坐标点串的形式存储起来。

A rcV iew 以其易用性和灵活性受到大量用户的喜爱,占有极高的市场占有率,广泛应用于国土资源、环境、地学等领域中。

现在S H P 文件格式已经成为G IS 界的一种标准格式,几乎所有的G IS 软件都支持对它的转换甚至支持对其直接进行读写操作,大量的工程项目也往往把SHP 文件格式作为首选格式,因而每个从事研究G IS 人员都应该详细的了解和掌握SHP 文件格式。

2 SHP 文件格式说明通常开发人员可以采用自带的开发软件包对资料的采集、入库、查询以及分析进行编程。

但是他们开发的地理信息软件包所处理的文件格式通常与S HP 格式不兼容。

但是如果清楚了S H P 文件的编码方式就可以利用常用的开发工具(如V C ,V B)等将自定义文件格式转换为S H P 文件格式。

不同于其它各种转换文件格式如M IF 、M I D 、E00等,S H P 文件格式采用编码效率较高的二进制格式。

点的坐标采用双精度保存,保证了点的精确度。

S HP 文件系统由三个文件组成:S H P 文件、S HX 文件和DBF 文件。

S H P 文件中存储每个地物的空间资料,S HX 文件主要存储了S HP 文件中每个地物元素的起始位置和所占字节的大小,D BF 文件存储每个地物元素的属性资料。

相对于向量图形中的每个元素,S H P 文件中都有相应的一个段落与之对应,所以其资料格式有一定的复杂性。

每个S H P 文件都包含一百个字节的文件头信息,文件头记录了文件中常用的基本信息,信息如表1所示:表1 主文件头的描述位置域值类型字节次序Byte 0文件代码9994整型B i g Byte 4未使用0整型B i g Byte 8未使用0整型B i g B yte 12未使用0整型B i g B yte 16未使用0整型B i g B yte 20未使用0整型B i g B yte 24文件长度文件长度整型B i g B yte 28版本1000整型Littl e B yte 32形状类型形状类型整型Littl e B yte 36边界盒X 坐标最小值双精度Littl e B yte 44边界盒Y 坐标最小值双精度Littl e B yte 52边界盒X 坐标最大值双精度Littl e B yte 60边界盒Y 坐标最大值双精度Littl e B yte 68边界盒Z 坐标最小值双精度Littl e B yte 76边界盒Z 坐标最大值双精度Littl e B yte 84边界盒M 最小值双精度Littl e B yte 92边界盒M 最大值双精度Littl e其中,0-3字节表示文件代码,固定值为9994,字节排列方式为倒序排列;3-19字节为空,固定值为0,字节排列方式为倒序排列;19-23字节为文件的大小,取值为文件的长度,字节排列方式为倒序排列(并以十六b it 存储);24-27字节为文件的版本,固定值为1000,字节排列方式为正序排列;28-31字节为地物的形状类型,取值如表二所示(x,y 为二维坐标,m 为度量坐标,z 为高程坐标),字节排列方式为正序排列:表2 形状类型值形状类型描述0NULL Shap e空地物类型1Poi n t 单点类型(包含x ,y 坐标)3Pol yL i ne 线类型(每个点包括x ,y 坐标)5Polygon 多边形类型(每个点包括x ,y 坐标)8M ulti Po i nt 多点类型(每个点包含x ,y 坐标)11Poi n t Z 单点类型(包含x ,y ,m,z 坐标)13Po l yL i neZ 线类型(每个点包含x ,y ,m,z 坐标)15Pol ygonZ 多边形类型(每个点包括x ,y ,m,z 坐标)18M u lti P oi n t Z 多点类型(每个点包括x ,y ,m,z 坐标)21Poi n M t单点类型(包括x ,y ,m 坐标)23Pol yL i ne M 线类型(每个点包括x ,y ,m 坐标)25Polygon M 多边形类型(每个点包括x ,y ,m 坐标)28M ulti P o i nM t多点对象(每个点包括x ,y ,m 坐标)32-100字节为四个坐标的范围,每个坐标占八位字节位。

在一个G IS 系统中,大部分工作是处理多边形地物元素,所以我们以多边形(Shape 文件中对应的Po l ygon 类型)为例,来探讨S H P 文件的编码方式。

每个Po l yg on 都有八比特的头信息,记录该P o lygon 的唯一标识和该P o lygon 所占有的字节数。

如表3所示:表3 多边形记录头信息位置域值类型字节次序0记录数Record N u m ber 整型B i g 4内容长度C onten t Lengt h整型B i g注意:内容长度是以16B it 存储。

在编程实现的时候其真实大小是该值的两倍。

头信息后存储为该多边形的坐标信息,存储的结构如表4所示:表4 多边形记录坐标信息位置域值类型数量字节次序B yt e 0形状类型3整型1Littl e B yt e 4边界盒Box 整型4Littl e B yt e 36部分数Nu m Parts 整型1Littl e B yt e 40点数NumPoi n ts 整型1Littl e B yt e 44部分串Parts 整型部分数Littl e Byte X点串Po i nts整型点数Littl e表4中形状类型字段代表地物的类型,因为该地物为多边形,所以为3,在表2中有介绍,该类型占四个字节;边界盒字段代表该多边形的X 、Y 坐标的最大和最小值,定义此字段的目的在于将该多边形所跨越的范围明确的固定下来,为空间查询提供依据;部分数字段代表该多边形包括的环的个数,在G IS 中,一个多边形包括多个环是很常见的;点数字段代表所有环所包含的顶点的个数;点串字段代表所有顶点的坐标序列,顶点的个数为N u mP o ints 。

图1为一个多边形的例子,这副图显示的是一个带洞的多边形地物元素,共有八个顶点。

在这个例子中,存在两个部分,共有十个顶点,顶点存储的顺序如图2所示。

3 应用说明应项目的需要,根据以上对S HP 文件的介绍,笔者利用V isual C ++开发环境,组织底层函数访问包对S H P 文件系统进行访问。

函数包的名称为S HPL i b ,该包是以面向对象的思想实现的,将S H P 文件中的点,线,面元素以类的形式表示出来,如面状元素在该库中表示为S H PP o l ygon 类,该类的主要属性包括面元素的I D,点串的坐标,范围等属性1整体的组织结构如图4所示:根据上面建立的函数库,笔者建立了一个应用程序模块L and XP ress ,该模块是针对土地利用现状图更新项目所做,该模块在向量方面包括以下功能11)向量资料的显示:对S H P 文件体系的空间资料和图3 S H PL i b 的组织结构属性信息进行了各种显示操作,包括放大、缩小、中心放大、中心缩小、漫游等。

2)向量空间资料的编辑:利用编辑工具可以对各种向量元素进行位置和顶点的移动和删除,利用合并和相交工具对面状地物元素进行合并和相交,在属性资料编辑窗口中可以对属性资料进行编辑,编辑完后可以对编辑后的空间和属性资料进行存储。

用户可以对向量资料进行颜色和填充模式的设置。

3)向量属性资料的编辑:在属性编辑窗口中利用属性资料编辑工具对属性资料进行编辑,包括,属性资料的删除,字段的添加和删除。

4)建立知识库:在栅格资料和向量资料迭加的情况下,在数据采集的模式下,对选中的和新添加的多边形元素进行各种常用属性信息的统计,包括各波段光谱值、光谱曲线、各波段极值特征、均值、方差、协方差、不变矩等,并将各种属性值入库。

5)文件的切割:以某个字段为参考字段,将该字段中值相同的元素重新放到一个新的文件中,为资料的后期更新做好准备。

6)与主流绘图软件、G IS 软件留有接口:可以直接使用主流的G IS 软件如A rc V ie w 、A rcG IS 等平台开发的成果,本模块编辑生成的资料可以直接在A rc V ie w 和A rcG IS 平台使用。

4 结论通过前面的描述,大家应该对多边形元素在SHP 文件中的具体表现形式以及如何以程序实现都有了一定的了解。

其它的向量图形元素如:点、线、路径等与多边形的表示方法基本类似,由于篇幅所限,笔者不能将其一一列举。

参考文献[1] 毛卫华,应荷香1DGN 资料格式转换的研究于实验[J].测绘通报,2001,(10):37O 391[2] 喻华1DGN 文件格式的探讨[J].测绘通报,2004,(10):52O 541[3] 张继贤1论土地利用与覆盖变化遥感信息提取技术框架[J].测绘科学,2003,(3):14O 161[4] 张继贤13S 技术支持得土地利用现状图更新[J].中国土地科学, 2001,16(1):20O 241[5] 张丽,张继贤1土地利用图件遥感快速更新方法的探索[J].测绘科学,2002,27(3):34O 361[6] 曾钰1土地利用基础图件更新软件系统的设计与开发[J]测绘科学,2005,(6):75O 771[7] 张继贤1单一时相遥感资料土地利用与覆盖变化自动检测方法[J ].测绘科学,2005,(4):295O 2991117第6期 刘 锋等 S HP 文件格式的研究与应用The App li cation of PPG IS in urban p l ann ing dec isi on Abstrac t:On the basis o f t he i n troduction o f PPG IS theory, this paper presen ts a fra m ewo rk o f PPG IS based on urban plann i ng dec i sion system firstly1T hen it ana l yses the o rganization f o r m of dis-tr i buted geo O database based on m etadata1F ina lly,it puts f o r w ard a conflict coordi na tion mechan i s m of publi c parti c i pati on,and con-structs a suitability ana lysism odel f o r PPG IS1K ey word s:PPG IS;distr i buted database;urban p lann i ng de-cisi on;con fli c t coo rd i nati onL I U L i n①②,TANG X i n O m i ng②,L I W an O wu③,QU G uo O q i ng①,ZHAO Yu O m e i④(①Coll ege o fG eo O i nfor m ation Science and Eng i neering,Shandong U n i versity o f Sc ience and T echno logy,Q ing-dao266510,China;②Ch i nese A cademy o f Survey ing and M ap-p i ng,Be iji ng100039,Chi na;③Co ll ege o f Info r m ati on Sc i ence and T echno l ogy,Shandong U n i versity o f Sc i ence and T echno l ogy, Q i ngdao266510,Ch i na;④Co lleg e of G eography and R esource M anagem ent,Ludong U niversity,Y anta i264025,Ch i na)S tudy on quality con trol of spatial da ta in th e Poyang lake area Ab stract:T he area o f P oyang L ake i s one of t he nine com-m erc ia l food production ba ses i n Ch i na1It's also the p l ace whe re fl oods o ften o ccur1In o rder to reduce the i m pa ct and da m ag e of fl oods on the li v es and properties o f people liv i ng i n t he Poy ang L ake A rea,the authors have deve loped a G eog raph ical Info r m a-ti on Sy ste m for preventing and contro lli ng fl oods i n the Poy ang L ake A rea w ith the strong assist of t he Sc i ence and T echno l og y O-f fice and t he W ate r Conserv ancy O ffi ce i n Jiangx i prov i nce1T he system uses v arious techn i que s to obta in,tran s m it and process spatia l da ta1T hese te chn i ques have produce a l a rg e quantity of m u lti source spatia l data,wh ich prov i des abundant and thorough info r m ation suppo rt for the fa st and accurate dec isi on on prev en-ti ng and contro lli ng fl oods,but,a t the sam e ti m e,needs a h i ghe r request to contro l the qua lity o f spa ti a l data1A ccord i ng to the oc-curr i ng sequence o f qua lity p rob l em s o f spa ti a l da ta,the authors classify these p rob l em s,analyse t he ir rea sons and propose a con-tro lm e thod1Th is pape r depicts and discusses the w ho l e process of the study,a t five stages of obta in i ng,storage,pro cess i ng,trans-i ti on and app lica ti on o f spatia l da ta1K ey word s:spati a l data;qua lity contro;l m etadata;G IS;Poy-ang L ake A reaL I U X iao O sheng①②,WU W ei O bo①(①Schoo l o f Env ironmenta l and A rchitectural Eng ineer i ng,JiangX i U niversity of Science and T echno l ogy,G anzhou341000,Ch i na;②C i v il Eng i neeri ng Instit u-te,T ong jiU n i versity,Shangha i200092,Ch i na)R esearch and app lication of S H P file format i n land over/u se m ap updati ngAb stract:In t he second l and O use search,mo st o f l and O use basic m ap is saved i n S H P file for m a t1So i n t he process of upda ti ng land O use basi c m ap,t he first proble m shou l d be so lved is to read and w rite o f S HP file f o r m at1In orde r to so l ve this prob le m,w e i n-terpret binary syste m i n t he S H P file for m a t parti cular and m aki ng the po l ygon e le m en t as exa m ple1Then,w e read and w rite the S HP file by progra mm i ng and app l y it i n pro ject su ffi c iency1K ey word s:land O use bas i c map;S HP file fo r ma t;po lygon e-l em entL I U Feng,ZHANG J i O x i an,L I H a i O tao(Chinese A cademy of Survey i ng andM app i ng,Beiji ng,100039)Prac tice of disaster manage m en t syste m based on G IS and R S Abstrac t:Chi na is a country w here t here have been frequent nature d i saste rs and have produced heavy casua lti es and econom i ca l losses every year1It has been an e ffective m eans t o dea lw ith d isas-ters by constructi ng disaster m anage m ent syste m,w hich has also brought about some good resu lts i n fact1In fact,disaster m anage-m ent is a l arge and com plicated run syste m wh i ch invo l ves many as-pects o f the m a tter1Based on G IS and R S,t h i s paper proposes som e pr i nciples and m eans f o r d i saste r m anag e m ent syste m1K ey word s:G IS;RS;disaster m anagementL I B i n,L I U Ji O pi ng,S H I L i O hong(Chi nese A cade m y o f Sur-vey i ng and M appi ng,Be iji ng100039,Chi na)Study on agen t O based techn i qu e for distri bu ted virtual G IS Abstract:O n t he basis o f trad itiona l m ulti O d i m ensi onal G IS techniques,ne w distr i buted V irtual G IS has been deve l oped by co m-b i n i ng v irtual rea lity and d i str i bu ted computati on techniques1W hen d istri buted V irt ua l G IS prope ls the appli cation of v irt ua l rea lity and G IS,it a lso bri ngs for w ard new prob le m s1In th i s paper,agent tech-no l ogy is app lied i nto the d istri buted V irtua l G IS,espec iall y d i scus-si ng the pr i nc i ples,design and arch itecture of agent O based d istri bu-ted v irtua l g eograph i c i nfor m a tion sy stem fro m the aspect o f i nte ll-i gent com putation and d i str i buted processi ng1T hen A g l e ts Soft w are Deve l op m ent K it from IB M is used to confir m the h i gh w ork i ng e ff-i ciency of agent O based distri buted V irtua l G IS by compar i ng w ith the traditi onal d istri buted system s1A t last,t h is paper su mm arizes the pro m isi ng app licati on of ag ent i n the distributed V irt ua l G IS,and m akes a prospect f o r it1K ey words:A gent;d istri buted;v irtua lG IS;ADVG IS;A g lets L I Q ian,L I M an O chun,HUA Q iang(D epa rt m en t of U rban and R esources Sciences,N an jing U niversity,N anji ng210093,Ch i na) Research and deve lop m ent of pub li c query syste m based on M O Abstract:B ased on ob ject O o riented techno logy o fG IS,this pa-per introduces character istic and adv antage o f second deve l op m en t syste m usi ng ComG IS andM ap O bjects1Comb i n i ng w it h the develop-m en t o f city G IS Publi c Q uery Syste m,t h is pape r e l abo ra tes the m ethod o f developi ng G IS appli cati on syste m using advanced prog ram langue C#and MO1In addition to t he functi on o f co mmon manage-m en t,t h is syste m has proper f unc ti on of G IS i n spa tia l ana l ysis and que ry1By the sa m e m ethod and techno logy,the si m ilar syste m can be estab lished,w hich has prac ti ca l sign ifi cance f o r enlarg i ng appl-i ca ti on scope and fie l d of G IS1K ey word s:G IS;M ap O bjects;ComG IS;public que ry sy stem KUANG Da i O zh i(R esources and Env iron m ent Science Q uanZhou N o r m al Co ll ege,Q uanzhou362000,Ch i na)W ave lets m ethod and its application to regressi on for monito-ring dataAb stract:A defor m ati on pred i ction mode l based on w ave l e t transfor m and regressi on esti m ati on is propo sed i n this paper1A s the w ave let coefficient is affected by thresho l d dur i ng wavelet decompos-i ti on,that is,no ise is restra i ned,the model is closed to the defor m a-ti on ru le and predicti on ism ore ex act1T he results show t hat the mode l i s effecti ve and suited to the pred i c tion o f defor m ati on m on itoring1K ey word s:pred icti on;wave let;regress i on;thresho l dJIANG T ing O chen①,ZHANG Q i ng②,JI AO M i ng O lian①, W ANG Ji O g ang①,W ANG X i u O pi ng①(①D ept1o f Space Info r ma-ti on Science,H ua H i a i Instit ute o f T echno logy,L ianyungang 222001,Ch i na;②Institute o f G eo O eng i neering and Survey i ng, Chang a'n U n i v ers it y,X ia'n710054,Ch i na)A parallel i m age m atch i ng al gor ithm runn i ng on clusterAbstract:It is t he key issue i n remo te sensing field to trans-for m m assive data i n t o i nfor m ation i n short ti m e1P arall e l i m age pro-cessi ng on h i gh perfo r m ance compu ti ng is one of t he key technolog i es to so lve th i s prob l em qu ick l y1T he pe rfor m ance o f para llel progra m i s close l y re l a ted to computer a rchitecture,besides CPU,i nc l udi ng sys-te m fra m e w ork,i nstructi on structure and access speed of storage u-n it1G ene ra lly there are severa l w ays to i m prove t he perfo r mance o f parallel progra m,such as coarse grain pa ra lle lis m,instruc ti on l eve l and m e m ory opti m izi ng1In this paper,a para llel i m ag e m atchi ng a-l go rith m on C l uste r is stud ied1Based on th i s a l gor it hm,t he i m ag e processi ng speed can be i m proved w ith the help of coarse g ra i n para-l le lis m,i nstruction leve l and m e m ory opti m izi ng1K ey word s:i m ag e m atch i ng;coarse g ra i n pa ra lle lis m;instruc-ti on l eve l opti m izi ng;memo ry opti m izi ng;c l usterZ HANG Chun O ling①,Q I U Zhen O ge②(①H e N an survey i ng and m apping bureau,Zhengzhou450052,Chi na;②K ey Laboratory o f N a-ti ona l surveyi ng and mappi ng bureau,C AS M,Beiji ng100039,China) A prac ticable m ethod of correcti on for at m os ph er ic refrac ti on i n p rec ise ED M trigono m e tr i c leve li n gAbstract:A t m ospher i c refraction i s the m a i n facto r to a ffect the#8#ABSTRACTS OF THE PRESENT ISSUE。

相关主题