MIF格式转SHP格式方法总结

MIF是mapinfo的数据文件,SHP是arcGIS的数据文件, 由MIF格式转成SHP格式,需要注意一点: MIF格式文件所在的目录不能太深,否则mapinfo9.5说转换不正确:

     MIF格式转SHP格式方法总结 - maoxp9 - 牛角尖---毛小平的空间

具体错误信息为: Unbalanced quotation marks encountered on line 1 of file G:\DOCUME~1\mao\LOCALS~1\Temp\ut_parm.txt -- line was `CFGenerate MIF SHAPE "C:\Temp\11\MapInfo交换格式\园分布图\" "G:\DOCUME~1\mao\LOCALS~1\Temp\fme72.tmp" LOG_STANDARDOUT YES +ID "队界" '

另外,有的MIF文件,特别的数据量大的线条文件被破坏掉, 不知是什么原因, 如线条文件,出现怪字符,这时需要手工将它们清掉,或采用程序, 后面附了其IDL程序,来读取MIF文件(注意, 只对线条文件pline arc region等,其它未做过多测试),并转换成正确的MIF文件,再准备由mapinfo9.5转;

打开mapinfo9.5,选择工具/通用转换工具/通用转换工具, 英文是Tools/Universal Translator/Universal Translator,弹出如下菜单,source选择mapinfo mid/mif,Destination选择ESRI.就OK

MIF格式转SHP格式方法总结 - maoxp9 - 牛角尖---毛小平的空间

IDL程序

pro mif_2_mif
 files = DIALOG_PICKFILE(/READ, FILTER = '*.mif',/MULTIPLE_FILES,/MUST_EXIST)

 for j=0,n_elements(files)-1 do begin
  file=files[j]
  v=str_sep(file,'.')
  nv=n_elements(v)
  if nv eq 1 then return
  midfile=strjoin(v[0:nv-2],'.')+'.mid'

  fileshp=strjoin(v[0:nv-2],'.')+'_a.mif'
  filemid=strjoin(v[0:nv-2],'.')+'_a.mid'

  openr,fp,file,/get_lun
  openr,midin,midfile,/get_lun
  version=''
  readf,fp,version
  v=str_sep(version,' ')
  if v[1] ne '450' then begin
   prom=dialog_message('MIF格式不是450版',title='转换出错')
   return
  endif
  openw,lun,fileshp,/get_lun
  openw,mid,filemid,/get_lun
  printf,lun,'Version 300'
  str=''
  str1=''
  readf,fp,str ;Charset
  printf,lun,str
  readf,fp,str ;Delimiter
  printf,lun,str
  for k=0,4 do begin
   readf,fp,str
   printf,lun,str
  endfor
 ; printf,lun,strmid(str,1)  ;坐标系统CoordSys
  readf,fp,str ;Columns
  printf,lun,str
  v=str_sep(str,string(9b))
  ncol=fix(v[1])
  for k=0,ncol-1 do begin
   readf,fp,str
   printf,lun,str
  endfor
  readf,fp,str ;Data
  printf,lun,str
  readf,fp,str ;''
  printf,lun,''
  ID=0L
  sum=0L
  err_num=0L
  while not eof(fp) do begin
   readf,fp,str ;Pline  186
markpline:
   u=str_sep(str,' ')
   if n_elements(u) eq 1 then u=str_sep(str,string(9b))
   ind=where(strlen(u) ne 0,count)
   if count eq 0 then continue   ;空行
   u=u[ind]
   type=u[0]
   case type of
   'Pline': begin
     n=long(u[1])
     p=dblarr(2,n)
     CATCH, Error_status
     IF Error_status NE 0 THEN BEGIN
      err_num=err_num+1
      print,'err=',sum
      while not eof(fp) do begin
       readf,fp,str
       if strpos(str,'Region') ge 0 then goto,markpline
       if strpos(str,'Pline') ge 0 then goto,markpline
       if strpos(str,'Text') ge 0 then goto,markpline
       if strpos(str,'Arc') ge 0 then goto,markpline
      endwhile
      break
     endif
     printf,lun,str
     readf,fp,p
     readf,midin,str
     printf,mid,str
     for k=0,n-1 do $
      printf,lun,p[*,k],format='(d0,1x,d0)'
     sum=sum+n
     ID=ID+1
    end
    'Text':begin
     printf,lun,str  ;'Text'
     readf,fp,str
     printf,lun,str  ;94942.38 1439....
     readf,midin,str
     printf,mid,str
    end
    'None':begin
     printf,lun,str  ;'Text'
     readf,fp,str
     printf,lun,str  ;94942.38 1439....
     readf,midin,str
     printf,mid,str
    end
    'Arc':begin
     printf,lun,str
     readf,midin,str
     printf,mid,str
    end
    'Region':begin
     readf,fp,str1
     n=long(str1)
     p=dblarr(2,n)
     CATCH, Error_status
     IF Error_status NE 0 THEN BEGIN
      err_num=err_num+1
      print,'err=',sum
      while not eof(fp) do begin
       readf,fp,str
       if strpos(str,'Region') ge 0 then goto,markpline
       if strpos(str,'Pline') ge 0 then goto,markpline
       if strpos(str,'Text') ge 0 then goto,markpline
       if strpos(str,'Arc') ge 0 then goto,markpline
      endwhile
      break
     endif
     printf,lun,str
     printf,lun,str1
     readf,fp,p
     for k=0,n-1 do $
      printf,lun,p[*,k],format='(d0,1x,d0)'
     readf,midin,str
     printf,mid,str
     sum=sum+n
     ID=ID+1    
    end
   else:begin
    if strmid(type,0,1) lt '0' or strmid(type,0,1) gt '9' then begin
     prom=dialog_message(file+'有不识别的类型'+type+',是否退出?',/question)
     if prom eq 'Yes' then goto,endall
    endif else begin      ;遇到填充子区时,中间是一个数字
     printf,lun,str
     while not eof(fp) do begin
      readf,fp,str
      if strpos(str,'Region') ge 0 then goto,markpline
      if strpos(str,'Pline') ge 0 then goto,markpline
      if strpos(str,'Text') ge 0 then goto,markpline
      if strpos(str,'Arc') ge 0 then goto,markpline
      printf,lun,str
     endwhile
    endelse
   end
   endcase
  endwhile
endall:
  free_lun,fp
  free_lun,midin
  free_lun,lun
  free_lun,mid
  print,'ID=',ID

 endfor

end

 

 

http://maoxp9.blog.163.com/blog/static/12265342009222819589/

 

.

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值