在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