资源描述
如何将TABMIF转换成SHP
———————————————————————————————— 作者:
———————————————————————————————— 日期:
6
个人收集整理 勿做商业用途
1、 通过MapInfo Professional来转,具体操作:Tools/Universal Translator/Universal
可以选上源文件和目标文件夹,可以直接选Tab文件,Mapinfo会自动把图层上的元素转换成arcgis的点、线、面图层。这个比拟简单,笔者已经成功。我是参考了一下的介绍:
MIF是mapinfo的数据文件,SHP是arcGIS的数据文件, 由MIF格式转成SHP格式,需要注意一点: MI格式文件所在的目录不能太深,否那么mapinfo9.5说转换不正确:
具体错误信息为: 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
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
2、 第二种方法是可以下载mif转shp工具,笔者下载了一个,但是运行转换时鼠标一直是等待状态,没有转换成功
3、 可以将TAB转换成MIF文件,然后再通过arcgis catalog的转换工具转换成shp,但是笔者没有成功,总是报错。具体操作是:
右键单击工具栏
Arcview 8x toolsàconversion toolsàMif to shapefile,在翻开的窗口上选择源文件和目标文件。
展开阅读全文