Hi again,
Yes it works for the data View, but I need to export the produced Map as a GeoTIFF. I have done this in version 9.3 using a VB-script:
Public Function Export_Layout_Geotiff()
On Error GoTo EH:
Dim pMxDoc As IMxDocument
Dim pDialog As IExportFileDialog, bOut As Boolean, pEnv As Envelope
Dim pMap As iMap
Dim pMapFrame As IMapFrame
Dim pExporter As IExport
Dim lOutputRes As Double
Dim deviceRECT As tagRECT
Dim printBounds As IEnvelope, pMapEnvelope As IEnvelope, exportEnvelope As IEnvelope
Dim pGraphicContainerLayout As IGraphicsContainer
Dim pPageLayout As IPageLayout
Dim mapFrameUL_X As Double, mapFrameUL_Y As Double, mapScale As Double, resolution As Double
Dim mapFrameUL_i As Double, mapFrameUL_j As Double
Dim mapBoundsElement As IElement
Dim mapBorderGeometry As IGeometry
Dim fileName As String
Dim pListDialog As IListDialog
Dim counter, nSelectedMap As Integer
Set pListDialog = New ListDialog
Set pMxDoc = ThisDocument
Set pEnv = New Envelope
nSelectedMap = 0
For counter = 0 To pMxDoc.Maps.Count - 1 Step 1
Set pMap = pMxDoc.Maps.Item(counter)
If pMap.Name = pMxDoc.FocusMap.Name Then
nSelectedMap = counter
End If
pListDialog.AddString pMap.Name
Next
bOut = pListDialog.DoModal("Choose the map for geo referencing:", nSelectedMap, _
Application.hWnd)
If Not bOut Then Exit Function
nSelectedMap = pListDialog.Choice
Set pMap = pMxDoc.Maps.Item(nSelectedMap)
Set pMxDoc.ActiveView = pMap
Set pPageLayout = pMxDoc.PageLayout
Set pMxDoc.ActiveView = pPageLayout
pMxDoc.ActiveView.Refresh
Set pGraphicContainerLayout = pMxDoc.PageLayout
Set printBounds = pPageLayout.Page.PrintableBounds
Dim PageW As Double
Dim PageH As Double
Dim pPage As IPage
Set pPage = pPageLayout.Page
pPage.QuerySize PageW, PageH
Set pMapFrame = pGraphicContainerLayout.FindFrame(pMap)
Set pMapEnvelope = pMapFrame.MapBounds
mapFrameUL_X = pMapEnvelope.UpperLeft.X ' Map Coord
mapFrameUL_Y = pMapEnvelope.UpperLeft.Y
Set mapBoundsElement = pMapFrame
Set mapBorderGeometry = mapBoundsElement.Geometry
If Not mapBorderGeometry.Envelope.UpperRight Is Nothing Then
mapFrameUL_j = mapBorderGeometry.Envelope.UpperLeft.Y ' Paper Coord
mapFrameUL_i = mapBorderGeometry.Envelope.UpperLeft.X
End If
Dim dX As Double, dY As Double, di As Double, dj As Double, scaleX As Double, scaleY As Double
With pMapEnvelope
dX = .UpperRight.X - .UpperLeft.X
dY = .UpperLeft.Y - .LowerLeft.Y
End With
With mapBorderGeometry.Envelope
di = .UpperRight.X - .UpperLeft.X
dj = .UpperLeft.Y - .LowerLeft.Y
End With
scaleX = dX / di
scaleY = dY / dj
mapScale = pMap.mapScale
Set exportEnvelope = New Envelope
deviceRECT = pMxDoc.ActivatedView.ExportFrame
exportEnvelope.PutCoords deviceRECT.Left, deviceRECT.bottom, deviceRECT.Right, deviceRECT.Top
Set pDialog = New ExportFileDialog
lOutputRes = 96
bOut = pDialog.DoModal(exportEnvelope, exportEnvelope, printBounds, lOutputRes)
If Not bOut Then Exit Function
Set pExporter = pDialog.Export
lOutputRes = pExporter.resolution
resolution = (25.4 * mapScale) / (1000 * lOutputRes)
With deviceRECT
.Left = 0
.Top = 0
.Right = pExporter.PixelBounds.XMax
.bottom = pExporter.PixelBounds.YMax
End With
Set fs = CreateObject("Scripting.FileSystemObject")
fileName = pExporter.ExportFileName
Dim pWorldFile As IWorldFileSettings
If pExporter.Name = "TIFF" Then
Set pWorldFile = pExporter
pWorldFile.OutputWorldFile = False
fileName = Mid(fileName, 1, Len(fileName) - 4) & ".tfw"
Set tfw = fs.CreateTextFile(fileName, True)
ElseIf pExporter.Name = "JPEG" Then
Set pWorldFile = pExporter
pWorldFile.OutputWorldFile = False
fileName = Mid(fileName, 1, Len(fileName) - 4) & ".jpw"
Set tfw = fs.CreateTextFile(fileName, True)
ElseIf pExporter.Name = "BMP" Then
Set pWorldFile = pExporter
pWorldFile.OutputWorldFile = False
fileName = Mid(fileName, 1, Len(fileName) - 4) & ".bpw"
Set tfw = fs.CreateTextFile(fileName, True)
ElseIf pExporter.Name = "GIFF" Then
Set pWorldFile = pExporter
pWorldFile.OutputWorldFile = False
fileName = Mid(fileName, 1, Len(fileName) - 4) & ".gfw"
Set tfw = fs.CreateTextFile(fileName, True)
ElseIf pExporter.Name = "PNG" Then
Set pWorldFile = pExporter
pWorldFile.OutputWorldFile = False
fileName = Mid(fileName, 1, Len(fileName) - 4) & ".pnw"
Else
Set tfw = fs.CreateTextFile(fileName, True)
fileName = fileName & ".tfw"
Set tfw = fs.CreateTextFile(fileName, True)
End If
tfw.WriteLine (resolution)
tfw.WriteLine (0)
tfw.WriteLine (0)
tfw.WriteLine (-resolution)
tfw.WriteLine mapFrameUL_X - mapFrameUL_i * scaleX
tfw.WriteLine mapFrameUL_Y + (PageH - mapFrameUL_j) * scaleY
tfw.Close
Dim expProgressor As IProgressor
Set expProgressor = Application.StatusBar.ProgressBar
Set pExporter.StepProgressor = expProgressor
Dim pCancel As ITrackCancel
Set pCancel = New CancelTracker
pMxDoc.ActivatedView.Output pExporter.StartExporting, lOutputRes, _
deviceRECT, Nothing, pCancel
pExporter.FinishExporting
Set pCancel = Nothing
Set pListDialog = Nothing
Set pEnv = Nothing
Set exportEnvelope = Nothing
Set pDialog = Nothing
EH:
Set pCancel = Nothing
Set pListDialog = Nothing
Set pEnv = Nothing
Set exportEnvelope = Nothing
Set pDialog = Nothing
End Function
Do you know of any way to do this in version 10 - how do I convert the VB-script to a Python-script?