Shapefiles zu MIF-Files

Hallo Forum,

ich muß zwecks Datenaustausch meine Shapefiles zu MIF-Files (für MapInfo) machen.
Dazu habe ich das folgende Skript bei Esri.com gefunden:
'

'Script THM2MIF V1.3

'User submitted script # 103


'--------------------------------------------------------------------- ---


'ESRI has not tested this script and therefor will not support it - read the DISCLAIMER. If you use this script, verify its safety and usability with test data first.

'Author's Email: tim.mcginnes@north.com.au


'--------------------------------------------------------------------

'NAME: util.ThemeToMIF
'FILE: thm2mif.ave
'DESCRIPTION: Exports theme to MapInfo MIF file
'CALL AS: av.Run("util.ThemeToMIF",nil)
'ARGUMENTS:
'RETURNS:
'EXPECTS: View to be active
'CALLS TO:
'DATE: 17/09/96
'AUTHOR: Tim McGinnes
'VERSION: 1.3
'REVISIONS: V1.1 7/2/96 MIF file requires extra info if coords not in deci-mal degrees
' -Added prompt to differentiate between metres and decimal degrees
' -Set correct no. of decimal places to use in MIF file
' -Added code to write correct header lines if fea-tures in metres
'
' V1.2 1/4/96 Fixed major problems with polygons that had "is-land" areas
' Fixed problem with field names (no dashes or spaces allowed)
' Fixed problem with integer fields (gave -1 for de-cimal precision)
'
' V1.3 17/9/96 GetExtent changed to ReturnExtent for ArcView 3.0
' Fixed problem with PLINE definitions in MIF
'
'Tim McGinnes
'North Limited
'Clarke St
'Parkes NSW 2870
'Australia
'tim.mcginnes@north.com.au
'--------------------------------------------------------------------


'Get required view and theme from user
number.setdefformat("d.")
view_choice=av.GetActiveDoc
themelist=view_choice.GetThemes
mytheme=msgbox.choice(themelist,"Choose theme to export:","Theme Choices")
if (mytheme=nil) then
exit
end
myftab=mytheme.GetFTab

'Get coord system from user
'NB-Script does not convert co-ordinates this only defines what co-ord system they are already in
coord_list={"Decimal Degrees","Metres"}
coord_choice=msgbox.choiceasstring(coord_list,"Choose coordinate system of the-me:","Coord System Choice")
if (coord_choice=nil) then
exit
end

'Get field definitions from theme - discard non numeric or non string fields
shapefield=myftab.FindField("shape")
myfieldlist=myftab.GetFields
flist=List.Make
fieldcount=myfieldlist.Count
fcount=fieldcount-1
for each tempnum in 0..fcount
currentfield=myfieldlist.Get(tempnum)
if ((currentfield.IsTypeNumber) or (currentfield.IsTypeString)) then
flist.Add(currentfield)
else
fieldcount=fieldcount-1
end
end
fcount=fieldcount-1

'Get output filename from user
outmifname=FileDialog.Put("untitled.mif".AsFileName,"*.mif","Choose MIF output file")
if (outmifname=nil) then
exit
end
outmiffile=LineFile.Make(outmifname,#FILE_PERM_WRITE)
outmidname=outmiffile.GetFileName
outmidname.SetExtension("mid")
outmidfile=LineFile.Make(outmidname,#FILE_PERM_WRITE)

'Write header line for MIF file
outmiffile.WriteElt("VERSION 300")
outmiffile.WriteElt("Charset ""WindowsLatin1""")
outmiffile.WriteElt("DELIMITER "",""")
if (coord_choice.Contains("Metres")) then
outmiffile.WriteElt("COORDSYS NonEarth")
outmiffile.WriteElt("Units ""m""")
'***** ArcView 3.0
' theme_extent=mytheme.ReturnExtent
'***** ArcView 2.x
theme_extent=mytheme.GetExtent
theme_left=theme_extent.GetLeft.setformat("d.dd").AsString
theme_right=theme_extent.GetRight.setformat("d.dd").AsString
theme_bottom=theme_extent.GetBottom.setformat("d.dd").AsString
theme_top=theme_extent.GetTop.setformat("d.dd").AsString
outmiffile.WriteElt("Bounds ("+theme_left+","+theme_bottom+") ("+theme_right+","+theme_top+")")
end
outmiffile.WriteElt("COLUMNS"++fieldcount.AsString)
for each tempnum in 0..fcount
currentfield=flist.Get(tempnum)
currentfieldname=currentfield.GetAlias
currentfieldname=currentfieldname.Substitute("-","_")
currentfieldname=currentfieldname.Substitute(" ","")
if (currentfield.IsTypeNumber) then
ftype="Decimal"
flength=currentfield.GetWidth.asstring
if (flength="-1") then
flength="0"
end
fdec=currentfield.GetPrecision.asstring
if (fdec="-1") then
fdec="0"
end
templine=currentfieldname++ftype++"("+flength+","+fdec+")"
end
if (currentfield.IsTypeString) then
ftype="Char"
flength=currentfield.GetWidth.asstring
if (flength="-1") then
flength="0"
end
templine=currentfieldname++ftype++"("+flength+")"
end
outmiffile.WriteElt(templine)
end
outmiffile.WriteElt("DATA")

'Write shape definitions to MIF file
for each rec in myftab
myshape=myftab.ReturnValue(shapefield,rec)
if (myshape.GetDimension=0) then
tempx=myshape.GetX
tempy=myshape.GetY
if (coord_choice.Contains("Decimal Degrees")) then
outmif-file.WriteElt("POINT"++tempx.setformat("d.dddddddd").asstring++ tempy.setformat("d.dddddddd").asstring)
else
outmif-file.WriteElt("POINT"++tempx.setformat("d.dd").asstring++tempy. setformat("d.dd").asstring)
end
end
if (myshape.GetDimension=1) then
tempshape=myshape.AsMultiPoint
templist=tempshape.AsList
tempcount=templist.Count
outmiffile.WriteElt("PLINE"++tempcount.asstring)
tempcount=tempcount-1
for each num in 0..tempcount
tempx=templist.Get(num).GetX
tempy=templist.Get(num).GetY
if (coord_choice.Contains("Decimal Degrees")) then
outmif-file.WriteElt(tempx.setformat("d.dddddddd").asstring++tempy.set format("d.dddddddd").asstring)
else
outmif-file.WriteElt(tempx.setformat("d.dd").asstring++tempy.setformat ("d.dd").asstring)
end
end
end
if (myshape.GetDimension=2) then
tempshape=myshape.AsPolygon
templist=tempshape.AsList
regioncount=templist.Count
polycount=0
outmiffile.WriteElt("REGION"++regioncount.asstring)
while (polycount0) then
outline=outline+","
end
outline=outline+""""+tempstr+""""
end
outmidfile.WriteElt(outline)
end
end

outmiffile.Close
outmidfile.Close


Nur leider kriege ich beim Kompilieren an der Stelle
outmif-file.WriteElt("POINT"++tempx.setformat("d.dddddddd").asstring++ tempy.setformat("d.dddddddd").asstring)
immer die Meldung "Ist keine Avenue-Anweisung".
Hilfe! Das ist mein erstes Skript und ich bin total hilflos.
Was muß ich tun, damit AV mir ein MIF-File schreibt?
Oder gibt es vielleicht eine funktionierende Extension?
Gruss,
Maggie
Hallo Maggie,

ist zwar lange her deine Frage, aber vielleicht wollen andere das Skript mal verwenden:

outmif-file.writeelt( ...

muss heissen:

outmiffile.writeelt( ...

denke ich.

Gruss

Uwe
Hallo Maggie.
Nur so nebenbei:
Warum die ganze Arbeit, Mapinfo kann bestens ShapeFiles importieren.
Ich würde mich in so einem Fall niemals auf irgendwelche Scripts verlassen.
Bitte nicht falsch verstehen, ich programmiere auch gerne, aber bei Dateikonvertierungen verzichte ich lieber darauf.
Mapinfo kann (und das ohne Probleme) Shapefiles importieren. Dies funktioniert ohne Umweg über das Export-Format MIF.

lg

Oliver