Automate layout production for multiple field values using the same template in ArcGIS Pro.

3958
10
Jump to solution
06-24-2020 08:49 AM
YusefSamari
Occasional Contributor

I am creating bird distribution maps for 133 different species over a defined geographic area. My dataset is a point feature class, where each row in the attribute table is an observation of a particular bird species from a survey, with fields for the species' name, the grid reference and it's breeding status.

The final map for each species should look something like the one below. The exact same template and extent will be used each time. In the example below I have applied a definition query on my bird observation layer (Species = 'Kingfisher') and applied a Graduated Symbols symbology to the breeding status.

I want to create a layout with the same template and extent showing the corresponding information for each species. There are 133 species and 3 survey periods - I really don't want to have change a definition query and species name in the text box almost 400 times! I figured this should be reasonably straightforward to automate in ArcGIS Pro, as it seems to me like it should be a fairly routine task for GIS users to have to create multiple maps of the same extent showing different features, or different values of a field in a feature class. So I was surprised to find that the Map Series functionality can only be defined by spatial extent, unless I'm missing something.

After spending a long time trawling for solutions it seems like the only way to do achieve what I want is to write a Python script that produces and exports the layout for each value in the 'species' field, and use a dynamic text box to change the name to the species that is filtered each time it does this. This would mean learning Python which I'm completely new to, but I'm happy to do that - I just wanted to check I'm not missing anything obvious first. 

If anyone could point me in the right direction as to how to about this, or point me to the best resources for learning what I need to do it, I would be extremely grateful.

0 Kudos
1 Solution

Accepted Solutions
Robert_LeClair
Esri Notable Contributor

Yusef - I found something that may assist with your map series question - Page Query's.  In the Contents Pane, go the layer properties for your bird species and select Page Query.  Here click the Bird Species field, Click Show Features that Match and click OK.  Now if you've already created the Map Series, then the map series "should" show only those bird species.  With regard to each map extent staying the same, in the Map Series->Map Extent properties, click Center and Maintain Scale based upon the current Map Frame Scale.  I'm still trying to figure out the Map Series Groupings...but it's a start.

View solution in original post

0 Kudos
10 Replies
Robert_LeClair
Esri Notable Contributor

Yusef - I found something that may assist with your map series question - Page Query's.  In the Contents Pane, go the layer properties for your bird species and select Page Query.  Here click the Bird Species field, Click Show Features that Match and click OK.  Now if you've already created the Map Series, then the map series "should" show only those bird species.  With regard to each map extent staying the same, in the Map Series->Map Extent properties, click Center and Maintain Scale based upon the current Map Frame Scale.  I'm still trying to figure out the Map Series Groupings...but it's a start.

0 Kudos
YusefSamari
Occasional Contributor

Thanks for the tip Robert! Sounds promising. I don't think I'll have time to work on this now till Monday, but will let you know how I get on!

YusefSamari
Occasional Contributor

Hi again Robert,

Thanks, that was just what I was looking for! I've used Page Query to successfully filter the bird survey data, and show only the species that matches the name of the page. 

Two issues I'm having now - one is that the resulting map series is showing a page for every row in my dataset, rather than a page for every species, so for each species I have an identical map for each observation of that species in the dataset.

Also, the extent is moving around slightly with each page, although the scale is staying the same.

Here's my workflow:

1. Set the Page Query for my Index Layer

2. Define my Index Layer in the Map Series tab, using the field I based the Page Query on as the Name Field and Sort Field

3. Selected Center and Maintain Scale on the Map Extent menu, using the Scale that was already in place from the Layout.

The extent is slightly shifting for each page, and I can't figure out how the extent is defined on each page. For example, two adjacent pages below:

This means that none of the templates have quite the right extent, as I had lined this up on the original template, and each page is shifted slightly. 

Any ideas on why the extent is shifting, or how to just have one page for each species, rather than for every row in the dataset?

Thanks for your help!

0 Kudos
YusefSamari
Occasional Contributor

Update: I have realised both of these issues are really just manifestations of one issue - the extent is shifting with each page because it is centred on each feature, and the map series is currently producing a page for each feature - each dot on the map. Still trying to find a way to have one page displaying all features that match each species name - rather than having a page for each individual feature...

TomBole
Esri Regular Contributor

Yusef, 

Have you considered creating a new feature class where each feature/row is for a specific species and each feature/row has the same geometry (point or polygon). You can use this feature class as the index layer for the map series.  If the geometry is the same for each feature the extent should not shift when navigating between the map series pages.  This new layer should have a field and values in the field that can be used in a Page Query for your existing point data.

Hope this helps, 

Tom

YusefSamari
Occasional Contributor

That's done it! Thanks a lot, Tom.

YusefSamari
Occasional Contributor

Update: I am now trying to batch export each page of the finished map series as individual PNG files.

I found an example Python snippet to do this here: MapSeries—ArcPy | Documentation 

I'm quite new to Python but I dived in trying to modify this to fit my own workflow. This is the best I could get after a few attempts:



The error message suggests something is wrong in the l.exportToPNG function, or maybe the os.path.join function within it. I had thought about just pasting the whole path straight into the l.exportToPNG function but thought then I wasn't sure how I'd automate changing the name for each PNG file. 

If anyone could point out where I'm going wrong here that would be much appreciated.

0 Kudos
Robert_LeClair
Esri Notable Contributor

I'm not a Python coder by any stretch of the imagination but I wonder if the space in your path is the issue?  Your current output path is C:\Yusef\Pembrokeshire SPACE Avifauna\Output\Ex2_Barn SPACE Owl.png.  Try removing the spaces or use an underscore instead.  Does the error message persist?

0 Kudos
YusefSamari
Occasional Contributor

I'm not sure. I thought that should have been fine because png files can have spaces in the filename. I tried creating a dummy dataset to base the map series on with no spaces in the species names. Still didn't work, although the error message was different:

0 Kudos