3

I'm building a code in Python to export in geotiff my imagery.

I need specific spots so I created a Data Driven Pages with polygons.

Everything works fine, except that my imagery layer takes a long time to be completely draw, and the output of my script shows just small parts of what I want. Please, see image below:

Time to load

So, what I need is a way to insert time.sleep in my python script to wait until imagery layer is completely loaded.

This is my script:

    mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
ar = df.extent.height / df.extent.width
for page_number in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = page_number
    print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
    arcpy.mapping.ExportToTIFF(mxd, r"C:\Users\Istus\Documents\XXXXXXXX\Imagery\mapas\GEOTIFF\map_" + str(page_number) + ".tiff", df, 9306,9306*ar, resolution=300, geoTIFF_tags=True)
del mxd

I'm using ArcMap 10.1 and Python 2.7.2.

3

I think I may have a solution for you. I have been testing with this a large data set I have, and this may be provide the results you're looking for.

Adding to your code:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
ar = df.extent.height / df.extent.width
for page_number in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = page_number
    #here I am taking the active data frame's extent and passing it back to the frame
    #ArcMap seems to hang at the point until it is rendered
    extent = df.extent
    df.extent = extent
    print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
    arcpy.mapping.ExportToTIFF(mxd, r"C:\Users\Istus\Documents\XXXXXXXX\Imagery\mapas\GEOTIFF\map_" + str(page_number) + ".tiff", df, 9306,9306*ar, resolution=300, geoTIFF_tags=True)
del mxd

I set up DD pages on my large data set and just added a print message after my extent change. I am watching it and it is rendering my layers (like 50+/-) before it prints my message and moves on. It is a bit hacky, but I didn't see any properties that tell if the data frame is drawing or not.

I don't have a big enough image to test it in the same way you're doing things so it looks like vector layers are drawing. If I can find a way to monitor drawing in arcpy, I will edit this answer.

0

I was also having the same issues. I found that if I didn't use my computer while the processing was being implemented, I wouldn't lose any data in the images.

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.