I have created a map series on ArcGIS Pro 2.5.1 displaying distribution data for different bird species over a UK county. Each page displays a different species. The index feature is a point feature class which is just a list of the different species, each with the same coordinates to centre the map. I want to export each page as a GIF file.
This Python code snippet from this help page seemed to be for the same general task:
https://pro.arcgis.com/en/pro-app/arcpy/mapping/mapseries-class.htm
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(relpath + "\\MapSeries\\US_States.aprx")
l = p.listLayouts()[0]
if not l.mapSeries is None:
ms = l.mapSeries
if ms.enabled:
for pageNum in range(1, ms.pageCount + 1):
ms.currentPageNumber = pageNum
print("Exporting {0}".format(ms.pageRow.STATE_NAME))
pageName = ms.pageRow.STATE_NAME
l.exportToPNG(os.path.join(relpath, "Output", f"Ex2_{ms.pageRow.STATE_NAME}.png"))
I have tried to modify this to fit my own workflow:
relpath = os.path.dirname("C:\Yusef\Pembrokeshire Avifauna\Breeding 2000s gif")
p = arcpy.mp.ArcGISProject("C:\Yusef\Pembrokeshire Avifauna\Pembrokeshire Avifauna_working.aprx")
l = p.listLayouts()[0]
if not l.mapSeries is None:
ms = l.mapSeries
if ms.enabled:
for pageNum in range(1, ms.pageCount + 1):
ms.currentPageNumber = pageNum
print("Exporting {0}".format(ms.pageRow.Species))
pageName = ms.pageRow.Species
l.exportToGIF(os.path.join(relpath, "Output", f"Ex2_{ms.pageRow.Species}.gif"))
For which I get the following error message, which I'm not sure how to interpet:
Traceback (most recent call last):
File "<string>", line 12, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_mp.py", line 1029, in exportToGIF
return convertArcObjectToPythonObject(self._arc_object.exportToGIF(*gp_fixargs((out_gif, resolution, gif_color_mode, clip_to_elements), True)))
OSError: C:\Yusef\Pembrokeshire Avifauna\Output\Ex2_Barn Owl.gif
Can anyone tell me what I'm doing wrong?