Saturday 12 January 2019

arcpy - Greater Than/Less Data Driven Page Definition Query?


I'm using data driven pages where each page is representing a series of points for a particular year. The problem I have is that I want to not only show the points for a particular year, I want to show each point before said year as well. So as I go through the pages, points are only being added to the map, not removed. I want to do a page definition query so that it would say:


"year" <= DataDrivenPageYear


The problem is that the Page Definition query only offers "Match" and "Don't Match." Is there something I can type in the regular query builder to tell it that I want the year less than or equal to the Data Driven Page year?



Answer



I agree with @FelixIP the current interface for ArcMap/Pro does not allow what you are asking for and can be solved with scripting only.


A untested alternative approach is this:




  • Set up your data driven pages as you have with definition query matching on page name field (year in your case).

  • From data driven pages tool bar add the page text for page name. This does not have to be physically on the layout page if you don't want to it in your pdf.

  • Set the NAME property of this text element, call it something "currentYear"

  • Write some python code that will run the data driven pages from a script, there are plenty examples in the help file, you need only open that and look at it.

  • The trick here is before calling the method exportToPDF you get a handle on your graphic element "currentYear" in your layout and read its text property which will contain the current year.

  • Having got a handle on the year you can set a definition query on your layer then you call the export.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...