Select to view content in your preferred language

Export a map series for each value in a field

266
2
Jump to solution
06-10-2026 10:06 AM
YusefSamari
Frequent Contributor

I am trying to create a map series to summarise species information from various taxonomic groups, for various sites, referred to here as 'patches'. The table below shows an example of the layer I am using for the spatial map series index layer. 'Patch_Taxon_Page' is the index field. 

I want to export a map series for each value of 'Patch_Name', that is saved somewhere with the value of Patch_Name as a file suffix. As if I were putting a definition query for each value of Patch_Name and exporting manually one at a time. Can anyone help me with some python code to do this from a notebook?

Patch_NameTaxon_GroupingPagePatch_Taxon_Page
Netpool ParkBird1Netpool Park_Bird_1
Netpool ParkVascular Plant2Netpool Park_Vascular Plant_2
Netpool ParkVascular Plant3Netpool Park_Vascular Plant_3
Mynydd Mawr Woodland ParkArachnid1Mynydd Mawr Woodland Park_Arachnid_1
Mynydd Mawr Woodland ParkBird1Mynydd Mawr Woodland Park_Bird_1
Mynydd Mawr Woodland ParkBird2Mynydd Mawr Woodland Park_Bird_2

 

Many thanks

 

1 Solution

Accepted Solutions
BrennanSmith1
Frequent Contributor

In your example, if you were to just export the entire series as PNG, would you end up with 6 different files named [Patch_Taxon_Page].png? You could just use a few lines of python to process those file names and aggregate them into two new PDFs named [Patch_Name].pdf.

import glob, os
from PIL import Image

folder = r"C:\Path\To\Your\PNGs"
pngs = glob.glob(os.path.join(folder, "*.png"))

for p in set(os.path.basename(f).split("_")[0] for f in pngs):
    imgs = [Image.open(f).convert("RGB") for f in pngs if os.path.basename(f).split("_")[0] == p]
    imgs[0].save(os.path.join(folder, f"{p}.pdf"), save_all=True, append_images=imgs[1:])

View solution in original post

0 Kudos
2 Replies
BrennanSmith1
Frequent Contributor

In your example, if you were to just export the entire series as PNG, would you end up with 6 different files named [Patch_Taxon_Page].png? You could just use a few lines of python to process those file names and aggregate them into two new PDFs named [Patch_Name].pdf.

import glob, os
from PIL import Image

folder = r"C:\Path\To\Your\PNGs"
pngs = glob.glob(os.path.join(folder, "*.png"))

for p in set(os.path.basename(f).split("_")[0] for f in pngs):
    imgs = [Image.open(f).convert("RGB") for f in pngs if os.path.basename(f).split("_")[0] == p]
    imgs[0].save(os.path.join(folder, f"{p}.pdf"), save_all=True, append_images=imgs[1:])
0 Kudos
YusefSamari
Frequent Contributor

Many thanks! I went down a slightly different route in the end, but this is also a good solution.

0 Kudos