Looking for ways to automate weekly map production (change title, count)

3796
6
11-11-2014 08:20 AM
PaulaCutrone
New Contributor II

Hello, I'm looking for ways to automate a couple of our repetitive map processes.  Each week my analysts go into individual Arc Maps to create .pdf exports of their respective crime types that are published on the Police Department's website.  They have to update the date range in the title (previous Monday through Sunday) and change the total count of crimes.  I was hoping there would be a way to have the date range automatically display by using a SQL statement similar to the one I use in the definition query:

 

ToDate Between DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) AND DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6)

 

I would also like to have the total number of crimes change based on how many are selected through the definition query.  It would be the equivalent of a count of the attributes, I think.

 

All of the maps are using definition queries based off the same view in SDE.  There are several analysts who are each responsible for their own crime type.

 

Any suggestions would be appreciated.  I have been researching this for a couple of weeks and am stuck.  Thank you!!!

0 Kudos
6 Replies
PaulaCutrone
New Contributor II

I haven't received any responses on this topic; I'm still looking for help! Thank you!

0 Kudos
WesMiller
Regular Contributor III

Paula Cutrone​ you can do these things with python if your interested I just recently finished a project for our planning department that does similar.The mapping module will hold most of the elements you'll need Introduction to arcpy.mapping—Help | ArcGIS for Desktop

IanMurray
Frequent Contributor

Wes is quite correct that the arcpy mapping module can take care of most of your needs.  You would probably need to set-up some map templates with all the layers, text elements, picture elements, legends, etc you will need on them(Naming all these elements making them significantly easier to access via the arcpy module). 

Using cursors you could pull data from the attribute table and apply them to various text elements on your map.  You could pull the current date via the python time module, and also created date information for the start of the week for display.  Once all the changes are made, you can save the map and export to pdf. 

I posted a script that I used alot of the arcpy.mapping module on this thread, if you need some examples. 

Custom brochure printing Python

PaulaCutrone
New Contributor II

Thank you Ian, I will check out your post.  I am new to using Python, so of course I have to start with an ambitious project.!

0 Kudos
PaulaCutrone
New Contributor II

Thank you Wes, I will definitely look into that.  I appreciate your time.

0 Kudos
WesMiller
Regular Contributor III

Paula just to help you get started see below. Use a blank arcmap with a layer and create a text element and use below to guide to get you through one.

#Get a reference to the current map document
mxd = arcpy.mapping.MapDocument("Current")
#Get a reference to the first dataframe
df = arcpy.mapping.ListDataFrames(mxd)[0]
#Get a reference to the desired layer I'm using "Property Lines" 
#but you may use whatever layer you want the name must be exactly like it is listed in your table of coontents
plyr = arcpy.mapping.ListLayers(mxd, "Property Lines", df)[0]
#Get a reference to a text element after you'created a text element you tight click and choose properties the choose the 
#"Size and Position" tab on the right side fill in the "Element Name", in this example I used "pcount"
txtelm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "pcount")[0]
# now we can fill in the text element with the layers count and a defintiion query is honored in the count
txtelm.text = int(arcpy.GetCount_management(plyr).getOutput(0))
#And lastly refresh the view so we a can see our work
arcpy.RefreshActiveView()