batch export jpeg with world files data driven pages

6703
16
06-16-2016 06:41 AM
AntoninGosset
New Contributor III

Hi there,

I'd like to know if it is possible to batch export jpg + world file (jpw or so) in batch using a Data Driven Pages python script.

I don't think it is possible because there is a limitation in Arcgis : the layout view doesn't permit the world file attachement and Data Driven Pages only exports layout views.

World file creation is only allowed in Data view.

I don't know if there is a trick / solution to do what I want to achieve using an advanced python script. A script that would run data driven pages in Layout View to export each view as JPG+ world file ?

Thanks

Example of python script to export Data driven pages as EMF in Data view

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

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

  mxd.dataDrivenPages.currentPageID = pageNum

  arcpy.mapping.ExportToEMF(mxd, r"J:\81B\____Répertoires Trafic\60-Contributions_autres_agences\62-Production\Paris\16_RFF_SCH_SECTEUR\3_production\A_SIG_SchSect\PRODCARTO\11_Prospective\Carte_" + str(pageNum) + ".emf", convert_markers=True)

  del mxd      

0 Kudos
16 Replies
AntoninGosset
New Contributor III

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

# Iterate map series pages 

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

   mxd.dataDrivenPages.currentPageID = pageNum 

   a = mxd.dataDrivenPages.pageNameField.name

print(a)

b = r "C:\Export" + "\\" + str(mxd.dataDrivenPages.pageRow.getValue(a)) + ".jpg"

print(b)

arcpy.mapping.ExportToJPEG(mxd, b, resolution=150, world_file=True) 

0 Kudos
AntoninGosset
New Contributor III

Parsing error SyntaxError: invalid syntax (line 7)

0 Kudos
DanPatterson_Retired
MVP Emeritus

Did you scrunch all this together to save space?

mxd.dataDrivenPages.pageRow.getValue

and what did this print?

print(a)

0 Kudos
AntoninGosset
New Contributor III

I just tried to make it work but apparently it didn't. I don't know programming so I don't know what I'm doing.

0 Kudos
FC_Basson
MVP Regular Contributor

Then start here: What is ArcPy?—Help | ArcGIS for Desktop

ArcPy/Python is an incredibly powerfull tool.  If you need to do this in the future again, do yourself a favour and learn Python.

0 Kudos
FC_Basson
MVP Regular Contributor

There's a space after the r before the pathname - not allowed.

0 Kudos
DavidBarnes
Occasional Contributor III

I'm not adept at python, but I think what you'd need to do is somehow cycle through each index feature in data view, zoom to the index feature, export the data view, then repeat with the next index feature, and so on.

0 Kudos