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?
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
|
show 2 more comments
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
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
|
show 2 more comments
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
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
arcpy arcgis-pro map-series
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
|
show 2 more comments
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
|
show 2 more comments
1 Answer
1
active
oldest
votes
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))
New contributor
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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))
New contributor
add a comment |
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))
New contributor
add a comment |
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))
New contributor
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))
New contributor
New contributor
answered 8 mins ago
Mick_ehMick_eh
1
1
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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