您的位置:首页 > 其它

shapefile转换evf 时岛的处理办法

2014-01-06 15:35 459 查看
在shp文件转换为evf的时候。如果shp文件的polygon存在岛的话,转换的evf是有问题的。解决方法,是读取shp中的所有部分。

pro shapefileToEvf
compile_opt idl2
ENVI, /RESTORE_BASE_SAVE_FILES
ENVI_BATCH_INIT, LOG_FILE='batch.txt'
;打开shp文件
shapefile='C:\Users\younglimpo\Desktop\掩膜\sheng.shp'
;读取投影信息,并由此创建投影文件
projstr='C:\Users\younglimpo\Desktop\掩膜\sheng.prj'
openr,lun,projstr,/get_lun
shpPrjString=''
readf,lun,shpPrjString
free_lun,lun
shapfeProjection=envi_proj_create(type=42,pe_coord_sys_str=shpPrjString)
;读取shp文件的信息

oshp=OBJ_NEW('IDLffShape',shapefile)
oshp->getproperty,n_entities=n_ent,Attribute_info=attr_info,n_attributes=n_attr,Entity_type=ent_type

;创建evf文件
ent=oshp->GetEntity(0)
N_VERTICES=ent.N_VERTICES
;错误解决办法
;就是是加入下面的两句代码

;
parts=*(ent.parts)
parts_ptr=[0,parts[1],-(parts[2]),-(parts[3]),-(N_VERTICES-1)]
vert=*(ent.vertices)
evfpath= 'd:\dhfTwoTest.evf'
evf_ptr = envi_evf_define_init(evfpath,$
projection=shapfeProjection,data_type=5,$
layer_name='省')
envi_evf_define_add_record,evf_ptr,vert,parts_ptr=parts_ptr,type=5
evf_id = envi_evf_define_close(evf_ptr,/return_id)
envi_evf_close,evf_id
attr=oshp->GetAttributes(/All)
;写入属性
envi_write_dbf_file, 'dhfTwoTest.dbf', attr
Obj_destroy,oshp

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shape 转换evf idl