I am having an issue when attempting to export to a TIFF in arcmap, using ArcPy in Python.

The full process I have scripted is as follows:

  1. Add rasters to a raster catalog
  2. panning to the raster data in the catalog layer in arcmap
  3. Exporting the result to a tiff

The above process loops through a total of 44 different raster catalogs, exporting each raster output to a different tiff name.

The odd thing is sometimes the error does not arise, other times I receive this error:

  • AttributeError: PageLayoutObject: Error in executing ExportToTIFF

A shortened version of the script is as follows:

# create geodatabase
arcpy.CreateFileGDB_management(outpath, "RasCat.gdb")
# set projection information for raster catalog
prjfile = BNG    
# set counter to 0
count = 1
# count raster files
total = len(RASTERF) # This is a table with all the raster names
for catalog in RASTERF:
            # output raster catalog
            outrascatp = os.path.join(gdbp,catalog)
            # create FGDB unmanaged raster catalog
            arcpy.CreateRasterCatalog_management(gdbp, catalog, prjfile, raster_management_type='UNMANAGED')

            # loop through tiles in 'tilestoadd' list
            for tile in tilestoadd:
               # tile tif file path
               tile1locp = os.path.join(outpath,tile[0],catalog+'.tif')
               tile2locp = os.path.join(outpath,tile[1],catalog+'.tif')
               tile3locp = os.path.join(outpath,tile[2],catalog+'.tif')
               tile4locp = os.path.join(outpath,tile[3],catalog+'.tif')
               # Load raster catalog         arcpy.RasterToGeodatabase_conversion(tile1locp+';'+tile2locp+';'+tile3locp+';'+tile4locp,outrascatp)
            count += 1


# sheet mxd path
mxdtypemxdp = os.path.join(newREPMATp,'TILE.mxd')
# duplicate sheet mxd path
mxdtypemxdp2 = os.path.join(newREPMATp,'TILE_copy.mxd')

# for every present 20x20 combination do the following
for product in AOIs:
    # mosaiced tiffs path
    mostifp = newREPMATp + '\\MOSTIFFS\\' + product
    *# Photoshop tiffs path
    PSp = os.path.join(newREPMATp,'PSTIFFS',product)
    # check if file path does not exist if not create file path
    # link to Photoshop
    psApp = Dispatch('Photoshop.Application')
    # run Photoshop in the background
    psApp.Visible = False
    # set the options for exporting in photoshop
    options = Dispatch('Photoshop.TiffSaveOptions')
    # ps_appLZWTIFFCompression
    options.ImageCompression = 2
    # no layers
    options.Layers = False*
    # the location of the AOI shapefile
    AOIfcp = os.path.join(outpath,'AOI',product+'.shp')
    # set 'AOItile' as an arcGIS layer
    AOI = arcpy.mapping.Layer(AOIfcp)

    # for every catalog in the geodatabase
    for dataf in RASTERF:
        # set mxd connection (SHEET)
        mxd = arcpy.mapping.MapDocument(mxdtypemxdp)
        #  set data frame
        df = arcpy.mapping.ListDataFrames(mxd, "SHEET DATA")[0]
        # get first layer in mxd
        lyrF = arcpy.mapping.ListLayers(mxd,'*',df)[0]
        # replace 'lyrF' data source
        # add 'AOItile' to mxd
        arcpy.mapping.AddLayer(df, AOI, 'BOTTOM')
        # pan to 20x20 tile AOI extent
        # save as 'mxdtypemxdp2' (SHEET_copy)
        # delete reference to original mxd, df, lyrF
        del mxd
        del df
        del lyrF
        # set new mxd connection
        mxd = arcpy.mapping.MapDocument(mxdtypemxdp2)
        #  set data frame
        df = arcpy.mapping.ListDataFrames(mxd, "SHEET DATA")[0]

        # change document view to page layout
        mxd.activeView = ("PAGE_LAYOUT")
        # refresh table of contents
        # refresh the view
        tiff = mostifp + '\\' + dataf+'.tif'
        # export mxd to TIFF format


        del mxd, df

I have looked up the error on many forums, one of them pointed towards the file path: Does arcpy have an issue with directory names starting with a number?

I was previously using the os module to control path concatenation e.g os.path.join(path1,path2) but have reverted it to the above script to rule this possibility out e.g path1 + '\\' + path2.

One more thing, I have run the script within ArcMap, ArcCatalog and Workflow Manager with the same result.

Software versions: ArcGIS 10.2.2 Python 2.7

  • You mention you've encountered the error in ArcMap, ArcCatalog and WFM. Is this all on the same machine? Or are you getting this behavior on multiple machines? Have you by any chance also had this error with a manual tiff export? – Dan_h_b Oct 16 '14 at 10:37
  • No I (or other users) recieve this error on different machines, I can manually export to Tiff from arcmap with no problems, I even tried manually opening and exporting from the mxd to TIFF once the error had arisen and can still successfully export. – Leroy Oct 16 '14 at 11:24

I think I may have solved it myself..

I was opening a template mxd, saving it as a new mxd, doing some changes then exporting to a tiff from the new mxd. Each time the loop run it was using the same template mxd, It is possible that at some point the reference to the mxd variable became locked (and did not update) so arc could not export the data from the new mxd to a tiff?

To get round this I did all the required changes and exported from the template mxd (removing the need to create a new the mxd or change the mxd variable). This seemed to solve the issue!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.