Data Driven Pages: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
mNo edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is a feature of ArcGIS Desktop.
This is a feature of ArcGIS Desktop.
2018-10-01 I've learned so much since I wrote this page, but I've already forgotten most of it.


Use Data Driven Pages when you want to create a map series (printed or pdf or ?)
Use Data Driven Pages when you want to create a map series (printed or pdf or ?)
Line 6: Line 8:
# Create an index to define the extent of each page along with things like the page title
# Create an index to define the extent of each page along with things like the page title
# Generate the maps by running the tool
# Generate the maps by running the tool
== Bike map ==


I want to create a map series for a long bike ride. Page one should show the whole route. Successive pages will each show a segment of the ride. I will generate a PDF file containing all maps.
I want to create a map series for a long bike ride. Page one should show the whole route. Successive pages will each show a segment of the ride. I will generate a PDF file containing all maps.


# I create a route in Garmin's BaseCamp.
=== Create a route ===
 
# I create a route in Garmin's BaseCamp. It's clumsy but does understand routing and can generate GPX files. I can use the GPX in my Garmin when I am on the road too.
# Select the route and then File->Export "Selected User Data"
# Select the route and then File->Export "Selected User Data"
# Save the route as a GPX file
# Save the route as a GPX file
Line 15: Line 21:
# File->Export "Selected User Data"
# File->Export "Selected User Data"
# Save the track as another GPX file
# Save the track as another GPX file
=== Import the route ===
# Jump over to ArcGIS.
# Jump over to ArcGIS.
# Use tool "GPX to features (Conversion)" to convert the route and track to feature classes.  
# Use tool "GPX to features (Conversion)" to convert the route and track to feature classes.  
# Convert the track to a line.
# Convert the track to a line.
# Use the line as input in the Strip Map Index Features tool. I made the box on my map 8"x8" so I build an index for that. I set the scale to 1:48000 to give a reasonable map for bicycling.
# Use the setup wizard in the Data Driven Pages toolbar to turn on DDP and use the index fc.


I had to add a TrackUp field to the index and calculate angle + 180 to get the maps to show Track Up instead of Track Down.
=== Build an index feature class ===
 
Decide how big you want each page and what reference scale it should use.
I made an 8x8" box on my layout for the main map, and decide 1:48000 gives me a map that's useful while riding. You get about 10-12 miles of riding per map page.
 
# Use the track line as input in the Strip Map Index Features tool.
# I set the scale to 1:48000 to give a reasonable map for bicycling.
# I set the page extent overlap to 10%.
 
=== Generate pages ===
 
By default if I use the Angle field, track (the direction of travel) is DOWN the page, not what I want! I added a TrackUp field to the index feature class and then used Field Calculate with
TrackUp = Angle + 180 to get the maps to show Track Up instead of Track Down.
 
Use the setup wizard in the Data Driven Pages toolbar to turn on DDP and use the index fc.
 
=== Make your map book ===
 
To use DDP to generate output in ArcMap you either "print" or "export".
 
In classic ESRI style, there is no feedback while it generates output other than a spinning cursor. So, when you run it and nothing appears to happen, maybe it works and it is slow or maybe it failed and is wasting your time. Your guess?
 
You can try outputting one page at a time! I did 1 page then 2 pages. That worked. Doing all 9? NOTHING.
 
I finally got it to work by some combination of removing nonvisible layers and turning off "Layers and attributes" in the Advanced tab in Export To PDF.
 
== More ideas ==


An exercise: Python script, to make a bookmark for each page (instead of using DDP toolbar).
An exercise: Python script, to make a bookmark for each page (instead of using DDP toolbar).
Line 28: Line 61:
   Generate a bookmark matching it
   Generate a bookmark matching it


Anoteher exercise: Write python to generate the strip index, and then have it insert the first row as an extent that covers the entire route with Angle set to 0 so that we have a north up overview as page 1 in the map book.
Another exercise: Write python to generate the strip index, and then have it insert as the first row as an extent that covers the entire route with Angle set to 0 so that we have a north up overview as page 1 in the map book. Then have it do the TrackUp calculation too.


The track is for a visual reference. The route is for creating the index.
The track is for a visual reference. The route is for creating the index.
Line 34: Line 67:
The maps will just use the ESRI [http://www.esri.com/software/arcgis/arcgisonline/features/maps
The maps will just use the ESRI [http://www.esri.com/software/arcgis/arcgisonline/features/maps
  ArcGIS Online] [https://www.arcgis.com/home/gallery.html#c=esri&t=maps&o=modified&f=basemaps-current Basemap] US topo for now. In ArcMap, use "Add Basemap" in the "add data" list.
  ArcGIS Online] [https://www.arcgis.com/home/gallery.html#c=esri&t=maps&o=modified&f=basemaps-current Basemap] US topo for now. In ArcMap, use "Add Basemap" in the "add data" list.


Can I have an elevation profile for the segment appear on each page?
Can I have an elevation profile for the segment appear on each page?
As long as we're generating profiles, we should generate those nifty chevrons that bicycle maps always have. I mean, why not? Steep steeper steepest! I am starting a separate page, [[Elevation profiles]].


Can I have an overview dataframe appear on each map?
Can I have an overview dataframe appear on each map?
Line 47: Line 80:


Can I have a block of text appear on only certain pages? For example, attribution for a layer.
Can I have a block of text appear on only certain pages? For example, attribution for a layer.
== Creating the index ==


== Page definition queries ==
== Page definition queries ==
Line 54: Line 85:
A page definition query allows you to control what shows up on a given page.
A page definition query allows you to control what shows up on a given page.


I frequently create a polygon layer that masks features and set it to be translucent white so that the features
outside the area of interest are faded out. I do this using the "does not match" option for Page Definition. It's handy to create
three groups in the TOC, "above mask", "below mask", and "mask". Some features should always show up even when there is a mask.
== Run python for every page ==
I don't want to run a separate script to generate the map series, because I want the mortals* to be able to just print one or more pages on their own.
Using an [[ESRI add-in]] that is controlled by the DDP tools makes this possible. Someone can page through the map using the DDP controls and as they do, the metadata are updated
to match. When they have the page displaying that they are interested in, they can just print it.
I do this by creating an [[ESRI add-in]], which I store in a shared network drive so that I can update the shared copy
and then tell the mortals to reload ArcMap so they get the new version.
An "[[ESRI add-in]]" is a ZIP file with the extension "esriaddin".
For the map series in question, I have it update the title block including picking a scale bar and building a table of numbers.
=== To tell ArcMap to watch a shared directory, ===
Go to ArcMap -> Customize -> Add-In Manager and click on the Options tab. You will see "Search for additional Add-Ins in these folders."
Use "Add Folder..." to add a shared network drive. I also keep my local source repo in there so that I don't have to jump through
hoops during development. So for example "C:\GEOMODEL\MAPPRODUCTION\ADDIN".
Also on this dialog you have to make sure "Load all Add-Ins without restrictions (Least Secure)" is selected.


=== To load the add-in, ===


Go to ArcMap Customize -> Extensions
and make sure your extensions e.g. "MAP DDP extension" is checked and has the description you created, such as "Watch for changes in DDP and update page layout."


My code defines an object called ddp_extension and has event handlers for


openDocument - loads pagenames
beforePageIndexExtentChange - does a print
pageIndexExtentChanged - calls update_page_layout to do all the heavy lifting


It has a function "load_pagenames" that it uses to populate the ddp list of names


*mortal - one who uses ArcMap without wanting to be a Python programmer, i.e. a normal healthy person.


[[Category: GIS]]
[[Category: GIS]]

Latest revision as of 16:33, 1 October 2018

This is a feature of ArcGIS Desktop.

2018-10-01 I've learned so much since I wrote this page, but I've already forgotten most of it.

Use Data Driven Pages when you want to create a map series (printed or pdf or ?)

  1. Create a layout to be used for each map in the series.
  2. Create an index to define the extent of each page along with things like the page title
  3. Generate the maps by running the tool

Bike map

I want to create a map series for a long bike ride. Page one should show the whole route. Successive pages will each show a segment of the ride. I will generate a PDF file containing all maps.

Create a route

  1. I create a route in Garmin's BaseCamp. It's clumsy but does understand routing and can generate GPX files. I can use the GPX in my Garmin when I am on the road too.
  2. Select the route and then File->Export "Selected User Data"
  3. Save the route as a GPX file
  4. Convert the route to a track and then select the track.
  5. File->Export "Selected User Data"
  6. Save the track as another GPX file

Import the route

  1. Jump over to ArcGIS.
  2. Use tool "GPX to features (Conversion)" to convert the route and track to feature classes.
  3. Convert the track to a line.

Build an index feature class

Decide how big you want each page and what reference scale it should use. I made an 8x8" box on my layout for the main map, and decide 1:48000 gives me a map that's useful while riding. You get about 10-12 miles of riding per map page.

  1. Use the track line as input in the Strip Map Index Features tool.
  2. I set the scale to 1:48000 to give a reasonable map for bicycling.
  3. I set the page extent overlap to 10%.

Generate pages

By default if I use the Angle field, track (the direction of travel) is DOWN the page, not what I want! I added a TrackUp field to the index feature class and then used Field Calculate with TrackUp = Angle + 180 to get the maps to show Track Up instead of Track Down.

Use the setup wizard in the Data Driven Pages toolbar to turn on DDP and use the index fc.

Make your map book

To use DDP to generate output in ArcMap you either "print" or "export".

In classic ESRI style, there is no feedback while it generates output other than a spinning cursor. So, when you run it and nothing appears to happen, maybe it works and it is slow or maybe it failed and is wasting your time. Your guess?

You can try outputting one page at a time! I did 1 page then 2 pages. That worked. Doing all 9? NOTHING.

I finally got it to work by some combination of removing nonvisible layers and turning off "Layers and attributes" in the Advanced tab in Export To PDF.

More ideas

An exercise: Python script, to make a bookmark for each page (instead of using DDP toolbar).

For each feature in the index feature class:
  Find centroid for each feature
  Generate a bookmark matching it

Another exercise: Write python to generate the strip index, and then have it insert as the first row as an extent that covers the entire route with Angle set to 0 so that we have a north up overview as page 1 in the map book. Then have it do the TrackUp calculation too.

The track is for a visual reference. The route is for creating the index.

The maps will just use the ESRI [http://www.esri.com/software/arcgis/arcgisonline/features/maps

ArcGIS Online] Basemap US topo for now. In ArcMap, use "Add Basemap" in the "add data" list.

Can I have an elevation profile for the segment appear on each page? As long as we're generating profiles, we should generate those nifty chevrons that bicycle maps always have. I mean, why not? Steep steeper steepest! I am starting a separate page, Elevation profiles.

Can I have an overview dataframe appear on each map?

Can I rotate each map so that I have direction of travel instead of north up?

Can I turn layers on or off on a page?

Can I turn on or off features like north arrows or scale bars?

Can I have a block of text appear on only certain pages? For example, attribution for a layer.

Page definition queries

A page definition query allows you to control what shows up on a given page.

I frequently create a polygon layer that masks features and set it to be translucent white so that the features outside the area of interest are faded out. I do this using the "does not match" option for Page Definition. It's handy to create three groups in the TOC, "above mask", "below mask", and "mask". Some features should always show up even when there is a mask.

Run python for every page

I don't want to run a separate script to generate the map series, because I want the mortals* to be able to just print one or more pages on their own. Using an ESRI add-in that is controlled by the DDP tools makes this possible. Someone can page through the map using the DDP controls and as they do, the metadata are updated to match. When they have the page displaying that they are interested in, they can just print it.

I do this by creating an ESRI add-in, which I store in a shared network drive so that I can update the shared copy and then tell the mortals to reload ArcMap so they get the new version.

An "ESRI add-in" is a ZIP file with the extension "esriaddin".

For the map series in question, I have it update the title block including picking a scale bar and building a table of numbers.

To tell ArcMap to watch a shared directory,

Go to ArcMap -> Customize -> Add-In Manager and click on the Options tab. You will see "Search for additional Add-Ins in these folders." Use "Add Folder..." to add a shared network drive. I also keep my local source repo in there so that I don't have to jump through hoops during development. So for example "C:\GEOMODEL\MAPPRODUCTION\ADDIN". Also on this dialog you have to make sure "Load all Add-Ins without restrictions (Least Secure)" is selected.

To load the add-in,

Go to ArcMap Customize -> Extensions and make sure your extensions e.g. "MAP DDP extension" is checked and has the description you created, such as "Watch for changes in DDP and update page layout."

My code defines an object called ddp_extension and has event handlers for

openDocument - loads pagenames
beforePageIndexExtentChange - does a print
pageIndexExtentChanged - calls update_page_layout to do all the heavy lifting

It has a function "load_pagenames" that it uses to populate the ddp list of names

  • mortal - one who uses ArcMap without wanting to be a Python programmer, i.e. a normal healthy person.