2

I have an arcpy script below to export a map book to pdf. The index layer are forty acre boundaries (township and range quarter sections). The data in the mxd is on an oracle database and updated nightly.
I want to use task manager to run the script nightly but I would like to add code so that only mxd's with edits/changes to the data in its geographic extent from the previous days version will export.
The reason for this is there are approximately 12,000 of these boundaries and it takes about 21 hours to run. I am hoping to dramatically reduce that. Here is the code:

import arcpy
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument(r"C:\SamplePath\SampleMXD.mxd")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  pageName = mxd.dataDrivenPages.pageRow.FORTYAC
  arcpy.mapping.ExportToPDF(mxd, r"C:\SamplePath\SampleFileName_" + str(pageName) + ".pdf")
del mxd

Any suggestions are much appreciated!

  • I am not sure what type of changes you want to track - but if you are changing your data as far as adding or deleting points - you could simply do a count of each feature class within the AOI and if that number for any dataset changes - export the map. You could keep this as a total in either a text file or using Pickle in python to save the numbers. – dklassen Oct 28 '13 at 22:18
  • @dklassen, It is a mapbook of schematics for electrical distribution. There are points lines and lots of annotation. I am trying to figure out some sort of loop so that if there is any delta to the data in an mxd in the map book, the mxd will export and write over the existing pdf for that map. – niemoy Oct 28 '13 at 22:23
  • Yes, when you say any delta/change - if you only care about number of features - then you can just do a count. If you care about attributes or geometry - then you would somehow have to have a previous version of this data to do a series of comparisons line by line - which might take longer than the actual export. I have never encountered this myself as a problem. – dklassen Oct 28 '13 at 22:38
  • 1
    Niemoy, the AOI is just an acronym for Area of Interest. Feature compare might work - but like I said before, it might take longer than exporting the PDF. It might be worth a shot. arcpy.FeatureCompare_management() is the arcpy script you would want to use. If you just want to do a simple feature count - you can use arcpy.GetCount_management() – dklassen Oct 29 '13 at 17:31
  • 1
    @niemoy, if you enable editor tracking on your featureclasses it will add some new fields which will record who made the last edit and when the last edit was made. You should then be able to search through your data based on this date stamp and only export the maps which hold data that has been modified in the last 24 hours. – Dan_h_b Oct 30 '13 at 16:19
1

As was mentioned in the comments, a solution would be to enable editor tracking on all of your data. This will automatically add timestamps to every record of the data to say when it was modified last.

Then use a definition query on your data to narrow it down to only the features that changed since the last export. Use this queried subset of data to select the index polygons (frames) of the map series that need to be re-exported (since they contain data that has changed).

This subset of index polygons can then be used to rebuild the map series or you could turn it into a list of page numbers and only export the page numbers that you have identified.

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.