Exporting MapSeries using index layer NAME, instead of page number, in ArcPy?Printing to PDF with Vector...

Skis versus snow shoes - when to choose which for travelling the backcountry?

GeometricMean definition

What is better: yes / no radio, or simple checkbox?

What is this waxed root vegetable?

Should I choose Itemized or Standard deduction?

If nine coins are tossed, what is the probability that the number of heads is even?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Find the next monthly expiration date

Where was Karl Mordo in Infinity War?

Does music exist in Panem? And if so, what kinds of music?

Non-Italian European mafias in USA?

What can I substitute for soda pop in a sweet pork recipe?

Make me a metasequence

What do the pedals on grand pianos do?

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

How do ISS astronauts "get their stripes"?

Why does the 31P{1H} NMR spectrum of cis-[Mo(CO)2(dppe)2] show two signals?

Exponential growth/decay formula: what happened to the other constant of integration?

When should a commit not be version tagged?

How would we write a misogynistic character without offending people?

Casually inserting sexuality

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

What to do when being responsible for data protection in your lab, yet advice is ignored?

chrony vs. systemd-timesyncd – What are the differences and use cases as NTP clients?



Exporting MapSeries using index layer NAME, instead of page number, in ArcPy?


Printing to PDF with Vector shapefiles, text, etc using ArcPy?Python and Data driven pages - Advanced usearcpy calculate zero number instead of negative numberExport individual Mapbook pages to PDFAvoiding loss of text (labels, legend, title, page numbers) when exporting many Map Series pages from ArcGIS Pro?Creating Strip Map Index using ArcGIS Pro?TerraGo Publisher for Arcgis automated using Python's PubPy libraryCloning LayoutListElements to PDF questionExporting text based PDF from ArcMap using ArcPy?Exporting all domains to table in ArcGIS Pro using ArcPy?













1















How can I write this python script to export each page in a MapSeries to a PDF, whilst using the MapSeries index layer NAME as the file name? At the moment, the script is configured to export using the page number.



Is it as simple as replacing 'ms.currentPageNumber' and 'pageNum' with 'ms.currentPageName' and 'pageNam'? And would the {0} need removing on the final line?



import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject("C:\Automation\Automation.aprx")
print ("project located")
l = p.listLayouts()[0]
print ("layouts listed")
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 page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
l.exportToPDF("C:\Users\Default\Production\Completed_certificates\Exported_PDF_file_{0}".format(str(ms.currentPageNumber) + ".pdf"))









share|improve this question

























  • If there is not something more direct you could always use list comprehension with a search cursor on the index layer to write a dictionary with objectid and page name as its key value pairs. Then use the dictionary to switch page number (objectid) for page name.

    – PolyGeo
    Feb 21 '18 at 11:38













  • @PolyGeo The index layer is updated every day, with new features replacing those from the previous day. If I understand what you're suggesting, I could not write a dictionary of all map index features, as I don't know what they will be called each day.

    – Theo F
    Feb 21 '18 at 11:57











  • The dictionary would be written as part of this script using one line of code that takes a second or two to run. I don't think it being volatile will be an issue.

    – PolyGeo
    Feb 21 '18 at 12:01











  • @PolyGeo ok fair. But I'll have to research how to do that. However, is there definitely no such thing as ms.currentPageName?

    – Theo F
    Feb 21 '18 at 13:55











  • The documentation should tell you that. I have not had chance to look.

    – PolyGeo
    Feb 21 '18 at 15:56
















1















How can I write this python script to export each page in a MapSeries to a PDF, whilst using the MapSeries index layer NAME as the file name? At the moment, the script is configured to export using the page number.



Is it as simple as replacing 'ms.currentPageNumber' and 'pageNum' with 'ms.currentPageName' and 'pageNam'? And would the {0} need removing on the final line?



import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject("C:\Automation\Automation.aprx")
print ("project located")
l = p.listLayouts()[0]
print ("layouts listed")
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 page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
l.exportToPDF("C:\Users\Default\Production\Completed_certificates\Exported_PDF_file_{0}".format(str(ms.currentPageNumber) + ".pdf"))









share|improve this question

























  • If there is not something more direct you could always use list comprehension with a search cursor on the index layer to write a dictionary with objectid and page name as its key value pairs. Then use the dictionary to switch page number (objectid) for page name.

    – PolyGeo
    Feb 21 '18 at 11:38













  • @PolyGeo The index layer is updated every day, with new features replacing those from the previous day. If I understand what you're suggesting, I could not write a dictionary of all map index features, as I don't know what they will be called each day.

    – Theo F
    Feb 21 '18 at 11:57











  • The dictionary would be written as part of this script using one line of code that takes a second or two to run. I don't think it being volatile will be an issue.

    – PolyGeo
    Feb 21 '18 at 12:01











  • @PolyGeo ok fair. But I'll have to research how to do that. However, is there definitely no such thing as ms.currentPageName?

    – Theo F
    Feb 21 '18 at 13:55











  • The documentation should tell you that. I have not had chance to look.

    – PolyGeo
    Feb 21 '18 at 15:56














1












1








1


1






How can I write this python script to export each page in a MapSeries to a PDF, whilst using the MapSeries index layer NAME as the file name? At the moment, the script is configured to export using the page number.



Is it as simple as replacing 'ms.currentPageNumber' and 'pageNum' with 'ms.currentPageName' and 'pageNam'? And would the {0} need removing on the final line?



import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject("C:\Automation\Automation.aprx")
print ("project located")
l = p.listLayouts()[0]
print ("layouts listed")
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 page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
l.exportToPDF("C:\Users\Default\Production\Completed_certificates\Exported_PDF_file_{0}".format(str(ms.currentPageNumber) + ".pdf"))









share|improve this question
















How can I write this python script to export each page in a MapSeries to a PDF, whilst using the MapSeries index layer NAME as the file name? At the moment, the script is configured to export using the page number.



Is it as simple as replacing 'ms.currentPageNumber' and 'pageNum' with 'ms.currentPageName' and 'pageNam'? And would the {0} need removing on the final line?



import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject("C:\Automation\Automation.aprx")
print ("project located")
l = p.listLayouts()[0]
print ("layouts listed")
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 page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
l.exportToPDF("C:\Users\Default\Production\Completed_certificates\Exported_PDF_file_{0}".format(str(ms.currentPageNumber) + ".pdf"))






arcpy arcgis-pro map-series






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 '18 at 11:35









PolyGeo

53.6k1780240




53.6k1780240










asked Feb 21 '18 at 11:10









Theo FTheo F

19810




19810













  • If there is not something more direct you could always use list comprehension with a search cursor on the index layer to write a dictionary with objectid and page name as its key value pairs. Then use the dictionary to switch page number (objectid) for page name.

    – PolyGeo
    Feb 21 '18 at 11:38













  • @PolyGeo The index layer is updated every day, with new features replacing those from the previous day. If I understand what you're suggesting, I could not write a dictionary of all map index features, as I don't know what they will be called each day.

    – Theo F
    Feb 21 '18 at 11:57











  • The dictionary would be written as part of this script using one line of code that takes a second or two to run. I don't think it being volatile will be an issue.

    – PolyGeo
    Feb 21 '18 at 12:01











  • @PolyGeo ok fair. But I'll have to research how to do that. However, is there definitely no such thing as ms.currentPageName?

    – Theo F
    Feb 21 '18 at 13:55











  • The documentation should tell you that. I have not had chance to look.

    – PolyGeo
    Feb 21 '18 at 15:56



















  • If there is not something more direct you could always use list comprehension with a search cursor on the index layer to write a dictionary with objectid and page name as its key value pairs. Then use the dictionary to switch page number (objectid) for page name.

    – PolyGeo
    Feb 21 '18 at 11:38













  • @PolyGeo The index layer is updated every day, with new features replacing those from the previous day. If I understand what you're suggesting, I could not write a dictionary of all map index features, as I don't know what they will be called each day.

    – Theo F
    Feb 21 '18 at 11:57











  • The dictionary would be written as part of this script using one line of code that takes a second or two to run. I don't think it being volatile will be an issue.

    – PolyGeo
    Feb 21 '18 at 12:01











  • @PolyGeo ok fair. But I'll have to research how to do that. However, is there definitely no such thing as ms.currentPageName?

    – Theo F
    Feb 21 '18 at 13:55











  • The documentation should tell you that. I have not had chance to look.

    – PolyGeo
    Feb 21 '18 at 15:56

















If there is not something more direct you could always use list comprehension with a search cursor on the index layer to write a dictionary with objectid and page name as its key value pairs. Then use the dictionary to switch page number (objectid) for page name.

– PolyGeo
Feb 21 '18 at 11:38







If there is not something more direct you could always use list comprehension with a search cursor on the index layer to write a dictionary with objectid and page name as its key value pairs. Then use the dictionary to switch page number (objectid) for page name.

– PolyGeo
Feb 21 '18 at 11:38















@PolyGeo The index layer is updated every day, with new features replacing those from the previous day. If I understand what you're suggesting, I could not write a dictionary of all map index features, as I don't know what they will be called each day.

– Theo F
Feb 21 '18 at 11:57





@PolyGeo The index layer is updated every day, with new features replacing those from the previous day. If I understand what you're suggesting, I could not write a dictionary of all map index features, as I don't know what they will be called each day.

– Theo F
Feb 21 '18 at 11:57













The dictionary would be written as part of this script using one line of code that takes a second or two to run. I don't think it being volatile will be an issue.

– PolyGeo
Feb 21 '18 at 12:01





The dictionary would be written as part of this script using one line of code that takes a second or two to run. I don't think it being volatile will be an issue.

– PolyGeo
Feb 21 '18 at 12:01













@PolyGeo ok fair. But I'll have to research how to do that. However, is there definitely no such thing as ms.currentPageName?

– Theo F
Feb 21 '18 at 13:55





@PolyGeo ok fair. But I'll have to research how to do that. However, is there definitely no such thing as ms.currentPageName?

– Theo F
Feb 21 '18 at 13:55













The documentation should tell you that. I have not had chance to look.

– PolyGeo
Feb 21 '18 at 15:56





The documentation should tell you that. I have not had chance to look.

– PolyGeo
Feb 21 '18 at 15:56










1 Answer
1






active

oldest

votes


















0














You can get the value of any field in the dataset which is used to generate the map series by using the ms.pageRow.FIELD_NAME



Try this:



l.exportToPDF("C:\Path_to_Output\Exported_PDF_file_{0}".format(str(ms.pageRow.NAME_FIELD) + ".pdf", 300))




share








New contributor




Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f272142%2fexporting-mapseries-using-index-layer-name-instead-of-page-number-in-arcpy%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can get the value of any field in the dataset which is used to generate the map series by using the ms.pageRow.FIELD_NAME



    Try this:



    l.exportToPDF("C:\Path_to_Output\Exported_PDF_file_{0}".format(str(ms.pageRow.NAME_FIELD) + ".pdf", 300))




    share








    New contributor




    Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      You can get the value of any field in the dataset which is used to generate the map series by using the ms.pageRow.FIELD_NAME



      Try this:



      l.exportToPDF("C:\Path_to_Output\Exported_PDF_file_{0}".format(str(ms.pageRow.NAME_FIELD) + ".pdf", 300))




      share








      New contributor




      Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        You can get the value of any field in the dataset which is used to generate the map series by using the ms.pageRow.FIELD_NAME



        Try this:



        l.exportToPDF("C:\Path_to_Output\Exported_PDF_file_{0}".format(str(ms.pageRow.NAME_FIELD) + ".pdf", 300))




        share








        New contributor




        Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        You can get the value of any field in the dataset which is used to generate the map series by using the ms.pageRow.FIELD_NAME



        Try this:



        l.exportToPDF("C:\Path_to_Output\Exported_PDF_file_{0}".format(str(ms.pageRow.NAME_FIELD) + ".pdf", 300))





        share








        New contributor




        Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share


        share






        New contributor




        Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 8 mins ago









        Mick_ehMick_eh

        1




        1




        New contributor




        Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Mick_eh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f272142%2fexporting-mapseries-using-index-layer-name-instead-of-page-number-in-arcpy%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

            Meter-Bus Содержание Параметры шины | Стандартизация |...