Select to view content in your preferred language

MapSeries Export to JPEG Issue

751
8
Jump to solution
09-12-2023 01:30 PM
ScoutStanley
New Contributor III

Hi, I am having a hard time figuring out how to get my script to export the layout as .jpg. The purpose of the script is that it loops through table and creates new layout based on the row value and then exports that layout. The script works perfectly with exportToPDF, but I can't figure out how to get exportToJPEG to work. Any ideas???

print("\n\tExporting map to pdf...")

        finallocationwithPIN = path.join(finallocation, PIN)
        if path.exists(finallocationwithPIN):
            remove(finallocationwithPIN)

        else:
            pass
        if not lyt.mapSeries is None:
            ms = lyt.mapSeries
            lyt.mapSeries.refresh()
            if ms.enabled:
                ms.currentPageNumber = ms.getPageNumberFromName(PIN)
                ms.exportToPDF(finallocationwithPIN)

 

0 Kudos
1 Solution

Accepted Solutions
HaydenWelch
Occasional Contributor II

In your example the layout object is the "lyt" object. Instead of using the mapseries in your loop, you just export the layout because after you set the active page the layout object holds that page.

So instead of the last line being "ms.exportToJPEG" it would be "lyt.exportToJPEG"

 

Sorry for the formatting I'm on mobile

View solution in original post

0 Kudos
8 Replies
RhettZufelt
MVP Notable Contributor

what does print(finallocationwithPIN) return?

R_

0 Kudos
ScoutStanley
New Contributor III

It returns the final location of where I want the layouts exported to. 

0 Kudos
ScoutStanley
New Contributor III

When I run script with  exportToJPEG, the error I get is..

AttributeError: 'MapSeries' object has no attribute 'exportToJPEG'

 

print("\n\tExporting map to pdf...")

        finallocationwithPIN = path.join(finallocation, PIN)
        if path.exists(finallocationwithPIN):
            remove(finallocationwithPIN)

        else:
            pass
        if not lyt.mapSeries is None:
            ms = lyt.mapSeries
            lyt.mapSeries.refresh()
            if ms.enabled:
                ms.currentPageNumber = ms.getPageNumberFromName(PIN)
                ms.exportToJPEG(f'{finallocationwithPIN}.jpg')

 

 

0 Kudos
EarlMedina
Esri Regular Contributor

The MapSeries itself has no exportToJPEG method is what's going on. What you're supposed to do is set the map series current page (as you are doing) and then export from the Layout object. I believe that means your last line should be:

lyt.exportToJPEG(finallocationwithPIN)

 

 

ScoutStanley
New Contributor III

Can you explain the what you mean by export from the layout object? 

0 Kudos
EarlMedina
Esri Regular Contributor

Take a look at example 2 here: MapSeries—ArcGIS Pro | Documentation. It's quite similar (I think) to what you're hoping to do.

0 Kudos
HaydenWelch
Occasional Contributor II

In your example the layout object is the "lyt" object. Instead of using the mapseries in your loop, you just export the layout because after you set the active page the layout object holds that page.

So instead of the last line being "ms.exportToJPEG" it would be "lyt.exportToJPEG"

 

Sorry for the formatting I'm on mobile

0 Kudos
ScoutStanley
New Contributor III

AH I see! Thank you for pointing out issue so clearly!! I was so deep in the weeds I was missing the obvious! Much appreciation!

0 Kudos