1

I have square grids of about 1000 polygons and i want to export TIFF images of each grid using a Python script, am having this below Python which gives me only .tiff images without referenced

mxd = arcpy.mapping.MapDocument("CURRENT")

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:\Temp\map_" + str(page_number) + ".tiff")

del mxd
1

You need to include the georeferencing world file when you export your .tif image. Also, you haven't set the format correctly, this should be ".tif", not "tiff". Please see ExportToTIFF documentation for more information.

Try the below:

arcpy.mapping.ExportToTIFF(mxd, r"C:\Temp\map_{}.tif".format(page_number), world_file=True) 
  • Dear MacroZED, thanks for your kind reply, it shows error if I run your script, please do elaborate on the world_file, – chandra Oct 24 '17 at 8:52
  • whats the error? – MacroZED Oct 24 '17 at 8:54
  • Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> KeyboardInterrupt – chandra Oct 24 '17 at 8:56
  • The string error is probably to do with the str(page_num). Did you incorporate the above into your code? or just run it on its own? If you try to run it on its one, it wont recognise the page_num. To test this, insert a page number instead of "page_num"...for eg try r"C:\Temp\map_1.tif" and see if it works. – MacroZED Oct 24 '17 at 8:59
  • mxd = arcpy.mapping.MapDocument("CURRENT") 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\LASA 27\Desktop\TST\Data Driven Pages" + str(page_number) + ".tif", world_file=True) del mxd this is what i did – chandra Oct 24 '17 at 9:07

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.