TransWikia.com

Creating Python code with ArcMap to export maps in jpg?

Geographic Information Systems Asked by Isabelle_OBVMR on November 1, 2021

I want to export maps that I have created on ArcMap 10.1 with this Python code:

mxd = arcpy.mapping.MapDocument("CURRENT") 
for i in range(1, mxd.dataDrivenPages.pageCount + 1): 
    mxd.dataDrivenPages.currentPageID = i 
    row = mxd.dataDrivenPages.pageRow
    print row.getValue("no lot")
    arcpy.mapping.ExportToJPEG(mxd, r"p:Isa2018_CS_Bilans_Hydriques_COPIECS images cadastre 1_" + str(row.getValue("no lot")) + ".jpg") 
del mxd 

The map is saved as JPEG, in a specific folder. I’ve tried this code before and it worked. I just changed the folder’s name in the code and tried to export other maps from the same project and it won’t work: it just produces an error code:

Runtime error 
Traceback (most recent call last): 
  File "<string>", line 5, in <module>
  File "C:program files (x86)arcgisdesktop10.1arcpyarcpyarcobjectsarcobjects.py", line 1011, in getValue 
    return convertArcObjectToPythonObject(self._arc_object.GetVa1ue(*gp_fixargs(args))) 
RuntimeError: ERROR 999999: Error executing function. 

How can I solve this?

One Answer

Not really an answer...I had a similar experience about a year ago. The export process, for some unknown reason, started throwing some error that I could never figure out. My first work around, to switch to a different export format worked for a short while until the same mysterious error was thrown. The frustration of it all forced me to use ArcGIS Pro and I never saw the error again. Perhaps that is an option for you?

Answered by palabria on November 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP