Layout

Synthèse

The Layout object references a single-page layout in an ArcGIS Pro project (.aprx). It provides access to common properties like page size and a number of different export methods.

Discussion

An ArcGIS Pro project can contain multiple page layouts. Layouts are accessed using the listLayouts method on the ArcGISProject object and it returns a Python list of Layout objects. It is important to uniquely name each layout so a specific page layout can be easily referenced by its name.

The listElements method provides access to all the elements on the page layout: GraphicElement, LegendElement, MapFrameElement, MapSurroundElement, PictureElement, and TextElement.

The Layout object is where you'll find access to a number of exportTo methods. Use the Layout export methods if you want to export the entire page layout. There is also a similar set of export methods available on the MapFrame class, if you only want to export the contents of a single map frame.

A layout can contain a single MapSeries. If the mapSeries property returns None, then a map series has not been created in the layout. You should also check to see if the map series is enabled before attempting to manipulate its properties.

Propriétés

PropriétéExplicationType de données
mapSeries
(Lecture seule)

Returns a MapSeries object if a spatial map series is enabled. It returns a NoneType if a map series does not exist or it is a bookmark map series.

MapSeries
metadata
(Lecture et écriture)

Get or set the layout's Metadata class information.

Remarque :
Setting metadata is dependent on the isReadOnly property value.

Metadata
name
(Lecture et écriture)

The layout's name. It is important that all layouts have a unique name so they can be easily referenced by name.

String
pageHeight
(Lecture et écriture)

A layout's page height based on the current pageUnits.

Double
pageUnits
(Lecture et écriture)

A layout's page units. Below is a list of valid strings when setting the page units.

  • CENTIMETERCentimeter
  • INCHInch
  • MILLIMETERMillimeter
  • POINTPoint
String
pageWidth
(Lecture et écriture)

A layout's page width based on the current pageUnits.

Double
URI
(Lecture seule)

The Universal Resource Indicator for a layout. It is a unique identifier for a layout in a project and is sometimes required when using Python CIM access. Once a layout is added and the URI is established, the value does not change over time. For example, if you modify the layout's name, the URI will not change.

String

Vue d’ensemble des méthodes

MéthodeExplication
exportToAIX (out_aix, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {clip_to_elements}, {keep_layout_background})

Exports the Layout to Adobe Illustrator Exchange (AIX) format. AIX files can be used with the ArcGIS Maps for Adobe Creative Cloud extension or Adobe Illustrator.

exportToBMP (out_bmp, {resolution}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile}, {clip_to_elements})

Exports the Layout to the Microsoft Windows Bitmap format (BMP).

exportToEMF (out_emf, {resolution}, {image_quality}, {output_as_image}, {clip_to_elements})

Exports the Layout to the Enhanced Metafile (EMF) format.

exportToEPS (out_eps, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})

Exports the Layout to an Encapsulated PostScript (EPS) format file.

exportToGIF (out_gif, {resolution}, {gif_color_mode}, {clip_to_elements})

Exports the Layout to Graphic Interchange Format (GIF).

exportToJPEG (out_jpg, {resolution}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile}, {clip_to_elements})

Exports the Layout to a Joint Photographic Experts Group (JPEG) format file.

exportToPAGX (out_pagx)

Exports the Layout to a page file (.pagx).

exportToPDF (out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {clip_to_elements}, {output_as_image}, {embed_color_profile}, {pdf_accessibility})

Exports the Layout to Portable Document Format (PDF).

exportToPNG (out_png, {resolution}, {color_mode}, {transparent_background}, {embed_color_profile}, {clip_to_elements})

Exports the Layout to a Portable Network Graphics (PNG) format file.

exportToSVG (out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})

Exports the Layout to the Scalable Vector Graphics format (SVG).

exportToTGA (out_tga, {resolution}, {color_mode}, {transparent_background}, {clip_to_elements})

Exports the Layout to the Truevision Graphics Adapter format (TGA).

exportToTIFF (out_tif, {resolution}, {color_mode}, {tiff_compression}, {jpeg_compression_quality}, {transparent_background}, {embed_color_profile}, {clip_to_elements}, {world_file}, {geoTIFF_tags}, {georef_mapframe})

Exports the Layout to a Tagged Image File Format (TIFF) file.

getDefinition (cim_version)

Gets a layout's CIM definition.

listElements ({element_type}, {wildcard})

Returns a Python list of page layout elements that exist on a Layout object.

openView ()

Opens and activates a new layout view pane in the application.

setDefinition (definition_object)

Sets a layout's CIM definition.

Méthodes

exportToAIX (out_aix, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {clip_to_elements}, {keep_layout_background})
ParamètreExplicationType de données
out_aix

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 300)

Integer
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(La valeur par défaut est BEST)

String
compress_vector_graphics

A Boolean that controls compression of vector and text portions of the output file. Image compression is defined separately.

(La valeur par défaut est True)

Boolean
image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVEAutomatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.
  • DEFLATEA lossless data compression.
  • JPEGA lossy data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(La valeur par défaut est ADAPTIVE)

String
jpeg_compression_quality

A number that controls compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 through 100. A jpeg_compression_quality of 100 provides the best-quality images but creates large export files. The recommended range is between 70 and 90.

(La valeur par défaut est 80)

Integer
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(La valeur par défaut est True)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(La valeur par défaut est True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean
keep_layout_background

If set to True, the layout's white background will be kept.

(La valeur par défaut est True)

Boolean

AIX is an Adobe Illustrator Exchange file exported from ArcGIS to be used with the ArcGIS Maps for Adobe Creative Cloud plug-in. When used with the plug-in, vector and raster map content is converted into editable, layered artwork for an improved editing experience in Adobe Illustrator. Once opened in Illustrator, it can be used for high-end graphic design or map finishing workflows and migrated across the other Adobe Creative Cloud applications.

exportToBMP (out_bmp, {resolution}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile}, {clip_to_elements})
ParamètreExplicationType de données
out_bmp

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
bmp_color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color

(La valeur par défaut est 24-BIT_TRUE_COLOR)

String
bmp_image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file. This option only applies to 8-bit bmp_color_mode options.

  • NONECompression is not applied.
  • RLERun-length encoded compression.

(La valeur par défaut est NONE)

String
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(La valeur par défaut est True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

BMP files are native Windows raster images. BMP files can store pixel data at several bit depths. BMP images are typically much larger than formats such as JPEG or PNG.

exportToEMF (out_emf, {resolution}, {image_quality}, {output_as_image}, {clip_to_elements})
ParamètreExplicationType de données
out_emf

A string that represents the system path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(La valeur par défaut est BEST)

String
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(La valeur par défaut est False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

EMF files are native Windows graphics files that can contain a mixture of vector and raster data. They are useful for embedding in Windows documents because the vector portions of the EMF can be resized without loss of quality. However, since EMF does not support font embedding and is exclusively a Windows format, it is not commonly used as an interchange format between users.

exportToEPS (out_eps, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})
ParamètreExplicationType de données
out_eps

A string that represents the system path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • DEFLATEA lossless data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(La valeur par défaut est DEFLATE)

String
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(La valeur par défaut est BEST)

String
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(La valeur par défaut est True)

Boolean
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(La valeur par défaut est False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

EPS files use the PostScript page description language to describe vector and raster objects. PostScript is the publishing industry standard for high-end graphics files, cartography, and printing. EPS files can be edited in many drawing applications or placed as a graphic in most page layout applications. EPS files support embedding of fonts so users who do not have Esri fonts installed can still view the proper symbology.

exportToGIF (out_gif, {resolution}, {gif_color_mode}, {clip_to_elements})
ParamètreExplicationType de données
out_gif

A string that represents the system path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
gif_color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale

(La valeur par défaut est 8-BIT_PALETTE)

String
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

GIF files are a legacy raster format for use on the web. GIF files cannot contain more than 256 colors (8 bits per pixel), which along with optional lossless compression, makes them smaller than other file formats.

exportToJPEG (out_jpg, {resolution}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile}, {clip_to_elements})
ParamètreExplicationType de données
out_jpg

A string that represents the path and file name of the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
jpeg_color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color

(La valeur par défaut est 24-BIT_TRUE_COLOR)

String
jpeg_quality

This value (0–100) controls the amount of compression applied to the output image. With a JPEG image, quality is adversely affected the more compression is applied. A higher quality (highest = 100) setting will produce sharper images and larger file sizes. A lower quality setting will produce more image artifacts and smaller files.

(La valeur par défaut est 80)

Integer
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(La valeur par défaut est True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

JPEG files are compressed image files. They support 24-bit color and are a popular choice for use on the web because a JPEG file size is often substantially smaller than many other image formats. However, the JPEG compression algorithm is lossy and is not recommended for many map images, as line drawings, and text or icon graphics, become blurred by compression artifacts. Therefore, PNG is usually a superior format for map images.

exportToPAGX (out_pagx)
ParamètreExplicationType de données
out_pagx

A string used to save a layout to a page file (.pagx).

String

This method is useful if you want to save a layout to a page file that can be imported later into a project using the ArcGISProject importDocument method.

exportToPDF (out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {clip_to_elements}, {output_as_image}, {embed_color_profile}, {pdf_accessibility})
ParamètreExplicationType de données
out_pdf

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 300)

Integer
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(La valeur par défaut est BEST)

String
compress_vector_graphics

A Boolean that controls compression of vector and text portions of the output file. Image compression is defined separately.

(La valeur par défaut est True)

Boolean
image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVEAutomatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.
  • DEFLATEA lossless data compression.
  • JPEGA lossy data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(La valeur par défaut est ADAPTIVE)

String
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(La valeur par défaut est True)

Boolean
layers_attributes

A string that specifies whether the PDF layer and PDF object data (attributes) will be included in the export file.

  • LAYERS_ONLYExport PDF layers only
  • LAYERS_AND_ATTRIBUTESExport PDF layers and feature attributes
  • NONENone

(La valeur par défaut est LAYERS_ONLY)

String
georef_info

A Boolean that enables the export of coordinate system information for each data frame into the output PDF file.

(La valeur par défaut est True)

Boolean
jpeg_compression_quality

A number that controls compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 through 100. A jpeg_compression_quality of 100 provides the best quality images but creates large export files. The recommended range is between 70 and 90.

(La valeur par défaut est 80)

Integer
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(La valeur par défaut est False)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(La valeur par défaut est True)

Boolean
pdf_accessibility

Output a tagged PDF file where text can be read by screen readers or other assistive technology. A tagged PDF file can include alt text—a text description of a graphic element that a screen reader uses to describe the element—for map frames, pictures, and chart frames. Alt text is added in the Element Pane for each element.

(La valeur par défaut est False)

Boolean

PDF files are designed to be consistently viewable and printable across various platforms. They are commonly used for distributing documents on the web, and the format is now an official ISO standard for document interchange. PDF files are editable in many graphics applications and retain map georeference information, annotation, labeling, and feature attribute data. PDF exports support embedding of fonts and can display symbology correctly even if the user does not have Esri fonts installed.

Review the PDFDocument class to learn more about how to manage PDF files, such as appending, inserting, and setting properties.

exportToPNG (out_png, {resolution}, {color_mode}, {transparent_background}, {embed_color_profile}, {clip_to_elements})
ParamètreExplicationType de données
out_png

A string that represents the path and file name of the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(La valeur par défaut est 32-BIT_WITH_ALPHA)

String
transparent_background

If set to True, the white page background is set to transparent.

(La valeur par défaut est False)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(La valeur par défaut est True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

A PNG file is a versatile raster format file that can display in web browsers and be inserted into other documents. It supports high-bit-depth color and uses a lossless compression. For maps, PNG is often the best raster format, since the lossless compression keeps text and line work legible by preventing the compression artifacts that can occur in JPEG format. PNG files can also define a transparent color.

exportToSVG (out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})
ParamètreExplicationType de données
out_svg

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
compress_to_svgz

If set to True, the output is compressed.

(La valeur par défaut est False)

Boolean
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(La valeur par défaut est BEST)

String
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(La valeur par défaut est True)

Boolean
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(La valeur par défaut est False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

SVG is an XML-based file format that has been specifically designed for viewing on the web. SVG can contain both vector and raster information. Some web browsers may require a plug-in to view SVG files. Older browsers may not be able to view SVG files at all. SVG supports font embedding, so users who do not have Esri fonts installed can still view SVG exports with proper symbology. You can also choose to produce compressed SVG files. The file extension changes to .svgz when this option is enabled.

exportToTGA (out_tga, {resolution}, {color_mode}, {transparent_background}, {clip_to_elements})
ParamètreExplicationType de données
out_tga

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(La valeur par défaut est 32-BIT_WITH_ALPHA)

String
transparent_background

If set to True, the white page background is set to transparent.

(La valeur par défaut est False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean

TGA files have historically been used for content that is meant to be used in other applications (for example, image sprites for animated games) and is read and written by many popular graphic arts applications. TGA format supports multiple bit depths including 32-bit with alpha (transparency) support.

exportToTIFF (out_tif, {resolution}, {color_mode}, {tiff_compression}, {jpeg_compression_quality}, {transparent_background}, {embed_color_profile}, {clip_to_elements}, {world_file}, {geoTIFF_tags}, {georef_mapframe})
ParamètreExplicationType de données
out_tif

A string that represents the path and file name of the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(La valeur par défaut est 96)

Integer
color_mode

This value specifies the number of bits used to describe color. The available options are dependent on the specified Color Model set in the layout's Color Management properties.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette. Available to RGB and CMYK.
  • 8-BIT_GRAYSCALE8-bit grayscale. Available to RGB and CMYK.
  • 24-BIT_TRUE_COLOR24-bit true color. Available only to RGB.
  • 32-BIT_WITH_ALPHA32-bit with alpha. Available only to RGB.
  • 32-BIT_CMYK_TRUE_COLOR32-bit CMYK true color. Available only to CMYK.
  • 40-BIT_CMYK_WITH_ALPHA40-bit CMYK with alpha. Available only to CMYK.

(La valeur par défaut est 24-BIT_TRUE_COLOR)

String
tiff_compression

This value represents a compression scheme.

  • DEFLATEA lossless data compression.
  • JPEGJPEG compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • PACK_BITSPack bits compression.

(La valeur par défaut est LZW)

String
jpeg_compression_quality

This value (0–100) controls the amount of compression applied to the output image. With a JPEG image, quality is adversely affected the more compression is applied. A higher-quality (highest = 100) setting will produce sharper images and larger file sizes. A lower-quality setting will produce more image artifacts and smaller files.

(La valeur par défaut est 80)

Integer
transparent_background

If set to True, the white page background is set to transparent.

(La valeur par défaut est False)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(La valeur par défaut est True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(La valeur par défaut est False)

Boolean
world_file

If set to True and a valid georef_mapframe is set, a world file will be generated based on the map frame's coordinate system.

(La valeur par défaut est False)

Boolean
geoTIFF_tags

If set to True and a valid georef_mapframe is set, geoTIFF tags will be embedded in the resulting image based on the map frame's coordinate system.

(La valeur par défaut est False)

Boolean
georef_mapframe

The MapFrame used to control the coordinate system when geoTIFF_tags are set to True.

(La valeur par défaut est None)

MapFrame

TIFF files are the best choice for importing into image editing applications and are also a common GIS raster data format. However, they cannot be natively viewed by a web browser.

getDefinition (cim_version)
ParamètreExplicationType de données
cim_version

A string that represents the major version of the CIM.

String

CIM-level access to additional object properties was introduced at ArcGIS Pro 2.4. When you want to return an object's CIM definition, you must specify a cim_version. Esri follows the semantic versioning specification. This means that at major releases—for example, 3.0—breaking API changes are allowed. This allows Python script authors control over which version of the CIM is used during a script run if there is a possibility breaking changes may be introduced in the new version. If you are authoring scripts for ArcGIS Pro 2.x, specify the cim_version to be 'V2'. If you are authoring scripts for ArcGIS Pro 3.x, specify the cim_version to be 'V3'. Scripts authored using cim_version 'V2' will continue to work in ArcGIS Pro 3.x.

For more information about working with the CIM and samples, see Python CIM access.

listElements ({element_type}, {wildcard})
ParamètreExplicationType de données
element_type

A string that represents the element type that will be used to filter the returned list of elements.

(La valeur par défaut est None)

String
wildcard

A wildcard is based on the element name and is not case sensitive. A combination of asterisks (*) and characters can be used to help limit the results.

(La valeur par défaut est None)

String
Valeur renvoyée
Type de donnéesExplication
List

A Python list of page layout elements. The types of objects that can be returned are GraphicElement, LegendElement, MapFrame, MapsurroundElement, PictureElement, and TextElement.

Each page element has a name property that can be set within the element properties dialog box. It is the layout author's responsibility to ensure each page element is given a unique name so that elements can be uniquely identified. If two elements have the same name, there is no way to ensure it is the element you want to reference.

The listElements method will return the elements within a group element into a flattened list. This makes it possible to easily search and replace text strings, for example, without having to navigate through a group element structure.

The element_type parameter can be skipped by passing an empty string or by including the parameter name for all parameters that follow the skipped parameter. For example


elm = lyt.listElements("", "Title")[0]

#or

elm = lyt.listElements(wildcard="Title")[0]

openView ()

This is useful if the layout view is not already open or another view is active in the application. The method creates a layout view zoomed to its full extent and activates it. To close other, existing views before opening a new view, use the ArcGISProject closeViews method.

Remarque :

This method is designed to be run in the application using a script tool, Notebook, or the Python window. It will have no effect if run outside of the application.

setDefinition (definition_object)
ParamètreExplicationType de données
definition_object

A modified CIM definition object originally retrieved using getDefinition.

Object

For more information about working with the CIM and samples, see Python CIM Access.

Exemple de code

Layout example 1

The following script uses the keyword current, so it should be run from the Python window. The script prints the name of each map in a project and its layers as well as the name of each layout and its page size.

aprx = arcpy.mp.ArcGISProject("CURRENT")
for m in aprx.listMaps():
    print("Map: " + m.name)
    for lyr in m.listLayers():
        print("  " + lyr.name)
print("Layouts:")
for lyt in aprx.listLayouts():
    print(f"  {lyt.name} ({lyt.pageHeight} x {lyt.pageWidth} {lyt.pageUnits})")
Layout example 2

The following script will update a map frame's area of interest by zooming to each bookmark that belongs to a map called Yosemite National Park and exports the result to individual PDF documents.

import arcpy, os
aprx = arcpy.mp.ArcGISProject(r"C:\Projects\YosemiteNP\Yosemite.aprx")

lyt = aprx.listLayouts("Main Attractions*")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "Yosemite National Park*")[0]

bkmks = mf.map.listBookmarks()
for bkmk in bkmks:
  mf.zoomToBookmark(bkmk)
  lyt.exportToPDF(os.path.join(r"C:\Projects\YosemiteNP", f"{bkmk.name}.pdf"))
del aprx
Layout example 3

The following script will check for the presence of a map series, then export two of its pages out to PDF.

import arcpy
import os
import sys
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:
        ms.currentPageNumber = ms.getPageNumberFromName("Rhode Island") 
        ms.exportToPDF(relpath + "\\Output\\Ex1_RI.pdf", "CURRENT", resolution=300)
        ms.currentPageNumber = ms.getPageNumberFromName("Washington") 
        ms.exportToPDF(relpath + "\\Output\\Ex1_WA.pdf", "CURRENT")