9 Replies Latest reply on Apr 18, 2012 6:28 AM by abrown31

    Export Layout as GeoTIFF in ArcGIS 10?

    vicsky
      Hi,
      Does anyone know how to export a Layout made in ArcGIS 10 as a GeoTIFF?

      Many thanks for any ideas!

      //Victoria
        • Re: Export Layout as GeoTIFF in ArcGIS 10?
          ptaurman-esristaff
          If you mean export the MXD to geotiff, you can go to File > Export Map, select TIFF in the Save as type, and at the bottom go to the Format tab, and check on Write GeoTIFF Tags.

          Patrick
          • Re: Export Layout as GeoTIFF in ArcGIS 10?
            vicsky
            If you mean export the MXD to geotiff, you can go to File > Export Map, select TIFF in the Save as type, and at the bottom go to the Format tab, and check on Write GeoTIFF Tags.

            Patrick


            Thanks for your reply, but the thing is that I can not select "Write GeoTIFF Tags" since it is greyed out. Do i need to have PLTS or is there any other way to do it? For ArcGIS 9.3.1 I have used a VB-script, but can not use the script in ArcGIS 10.

            Many thanks for your assistance on this.
            • Re: Export Layout as GeoTIFF in ArcGIS 10?
              ptaurman-esristaff
              You have to be in Data View and not Layout View.
              • Re: Export Layout as GeoTIFF in ArcGIS 10?
                vicsky
                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?
                • Re: Export Layout as GeoTIFF in ArcGIS 10?
                  vicsky
                  Anyone with any ideas? I still have not found a solution to this problem, so all thoughts are highly appreciated.


                  //Victoria
                  • Re: Export Layout as GeoTIFF in ArcGIS 10?
                    johns
                    This probably won't help but since you aren't getting any answers I'll offer it as something you might fiddle with. This is python window code I got from the 10.1 beta forums for exporting to a georeferenced tif. It is for the Data Driven Pages although that is easy to set up even for one a single export.  You would substitute your map document name, data frame name and paths.

                    My problem is I can't get it to produce a properly georeferenced tif from layout or view (although it seems to do either equally well); it is in the right "location but slightly rotated and compressed E-W.  I figure the problem is mine, however, so you might make it work.

                    I just noticed that when this is posted it makes no sense, the indents are lost and the word wrapping is odd.  So I'll separate the lines to deal with word wrapping, and note that the two lines after the statement beginning with "for" should be indented to work; one beginning with mxd and the other with arcpy.  The third and last line after the for statement is not indented and it begins with del.

                    import arcpy

                    mxd = arcpy.mapping.MapDocument(r"C:\GIS\Moxie\a_maps_covertype testDDP_Mapbook_covertype_2010_anno.mxd")

                    df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

                    for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):

                    mxd.dataDrivenPages.currentPageID = pageNum

                    arcpy.mapping.ExportToTIFF(mxd, r"C:\GIS\Moxie\a_maps_covertype\testDDP_Mapbook_covertype_2010_anno_Page" + str(pageNum) + ".tif", df, df_export_width=6119, df_export_height=5706, geoTIFF_tags=True)

                    del mxd
                    • Re: Export Layout as GeoTIFF in ArcGIS 10?
                      johns
                      I just got a confirmation that it may not be me, or even the code per se, but there may be a bug in ArcGIS causing the exported geotiff to be distorted.  So I guess you can skip trying the code out.  Sorry.
                      • Re: Export Layout as GeoTIFF in ArcGIS 10?
                        CareysDrum
                        I am having the greyed out problem as well, ever figure this out?
                        • Re: Export Layout as GeoTIFF in ArcGIS 10?
                          abrown31
                          I am having the greyed out problem as well, ever figure this out?


                          You have to be in Data View instead of Layout view to export.