AnsweredAssumed Answered

Data Driven Pages - Creating folders

Question asked by Entsika_Liesl on Oct 30, 2018
Latest reply on Oct 30, 2018 by Entsika_Liesl

Hi All,

 

I am new to python, and was wondering if there is a way to incorporate folder creation as part of my data driven page script, see below:

 

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

... df = arcpy.mapping.ListDataFrames(mxd)[0]

...

... in_folder = arcpy.GetParameterAsText(0)

... file_name = arcpy.GetParameterAsText(1)

...

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

...     mxd.dataDrivenPages.currentPageID = pageNum

...     pageName = mxd.dataDrivenPages.pageRow.Name

...     arcpy.mapping.ExportToJPEG(mxd, r"C:\Folder path\ " + pageName + "_Landcapability.jpeg", resolution=250) 

... del mxd

... del df

 

So basically I have 12 data sets consisting of either raster or vector data sets and one main data set (properties) which forms my data driven page. What I will do is, I will for instance switch on my land capability data set and run the script, when it is finished I will switch the next data set on and run the script again until I finished all 12 data sets. My pageName is the property code, therefore I will have 12 maps per property code. I then go and create folders for each property code, lets say 001 and move all 12 maps into that folder, and so forth for the rest. Is there a way of optimising this process, so that I don't manually have to switch on and of the layers and also so that I don't have to go manually create folders for each property code. It is over a 1000 properties, so currently it is a very time consuming process.

 

Any help will be appreciated.

Outcomes