Layout

サマリー

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

説明

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 layout can be easily referenced by its name.

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

The Layout object is where you'll find access to various 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 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, a map series has not been created in the layout. You should also check to see whether the map series is enabled before attempting to manipulate its properties.

The createLayout method on the ArcGISProject object allows you to completely automate the creation of a layout. Once a layout exists, there are many additional creator methods for creating the different types of layout elements. The layout object has three create methods for creating elements that can only exist on a layout. They are createMapFrame, createMapSurroundElement, and createTableFrameElement. The ArcGISProject object includes more create methods that allow you to create elements in a layout or in a graphics layer in a map. Those methods are createGraphicElement, createGroupElement, createPictureElement, createPredefinedGraphicElement, and createTextElement.

The openView method allows you to open a new view pane of your layout. There are currently no ways to determine whether a view is already open or whether your layout view is active because views can't be queried. What you can do is use the closeViews method on the ArcGISProject object and call openView on your layout. This will open and activate your layout so that it has the area and focus you might want.

注意:

The openView and closeViews methods only work for scripts run from within the application. Stand-alone scripts can't access view panes.

プロパティ

プロパティ説明データ タイプ
mapSeries
(読み取り専用)

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
(読み書き)

Get or set the layout's Metadata class information.

注意:
Setting metadata is dependent on the isReadOnly property value.

Metadata
name
(読み書き)

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

String
pageHeight
(読み書き)

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

Double
pageUnits
(読み書き)

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

  • CENTIMETERCentimeter
  • INCHInch
  • MILLIMETERMillimeter
  • POINTPoint
String
pageWidth
(読み書き)

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

Double
URI
(読み取り専用)

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

方法の概要

方法説明
changePageSize (page_width, page_height, {resize_elements})

The changePageSize method modifies the size of a layout.

createBookmarkMapSeries (mapframe, {bookmarks})

This method creates a new BookmarkMapSeries for a layout.

createMapFrame (geometry, {map}, {name})

The createMapFrame method creates a MapFrame element in a layout.

createMapSurroundElement (geometry, mapsurround_type, {mapframe}, {style_item}, {name})

The createMapSurroundElement method creates a MapSurroundElement in a layout.

createSpatialMapSeries (mapframe, index_layer, name_field, {sort_field})

This method creates a spatial MapSeries object for a layout.

createTableFrameElement (geometry, {mapframe}, {table}, {fields}, {style_item}, {name})

The createTableFrameElement method creates a TableFrameElement object in a layout.

deleteElement (element)

The deleteElement function deletes a layout element.

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}, {convert_markers})

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}, {convert_markers})

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}, {convert_markers})

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}, {keep_layout_background}, {convert_markers}, {simulate_overprint})

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}, {convert_markers})

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 in a Layout object.

openView ()

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

setDefinition (definition_object)

Sets a layout's CIM definition.

方法

changePageSize (page_width, page_height, {resize_elements})
パラメーター説明データ タイプ
page_width

A double that indicates the width of a layout and is based on the page_units value.

Double
page_height

A double that indicates the height of a layout and is based on the page_units value.

Double
resize_elements

Specifies whether the elements will be resized. If set to True, the elements on the layout will be resized proportionally. If set to False, only the page size will change, the elements will remain their original size.

(デフォルト値は次のとおりです True)

Boolean

The input size parameters are based on the layout's page_units value and the units cannot be changed.

createBookmarkMapSeries (mapframe, {bookmarks})
パラメーター説明データ タイプ
mapframe

A MapFrame that will have its camera settings driven by the information persisted in the bookmarks provided.

MapFrame
bookmarks
[bookmarks,...]

A list of Bookmark objects from either a single map, or multiple maps. If a list is not provided, the bookmarks that belong to the map associated with the map frame will be used instead.

List
戻り値
データ タイプ説明
Object

Returns a reference to the new BookmarkMapSeries object.

A bookmark map series page is created for each bookmark. Refer to the BookmarkMapSeries help topic for more information and code samples.

createMapFrame (geometry, {map}, {name})
パラメーター説明データ タイプ
geometry

The appropriate Point, or Polygon object that will be used to construct the element using page units.

Object
map

The Map associated with the MapFrame. If the default value of None is used, it can be changed at a later time.

(デフォルト値は次のとおりです None)

Map
name

An optional string that represents the name of the new MapFrame element. If a name is not provided, the default name value will follow the automatic sequencing nomenclature, for example, Map Frame, Map Frame 1, Map Frame 2, and so on.

String
戻り値
データ タイプ説明
MapFrame

If a variable is provided, it will reference the newly returned MapFrame object.

A map frame does not have to be associated with a map when created and the default value is None. If the element is created using a point geometry, the point location will represent the anchor position and there will be a default size. Later you can resize the element using the elementWidth and elementHeight properties.

Refer to the MapFrame class help topic for more information and code samples.

createMapSurroundElement (geometry, mapsurround_type, {mapframe}, {style_item}, {name})
パラメーター説明データ タイプ
geometry

A Point or a Polygon object that will be used to construct the element. The map surround types have different anchor locations so if you are creating an element with a point geometry, you will need to consider positioning relative to the default anchor location.

Object
mapsurround_type

A string that represents the map surround element that will be created

  • LEGENDA legend element will be created.
  • NORTH_ARROWA north arrow element will be created.
  • SCALE_BARA scale bar element will be created.
String
mapframe

The MapFrame element that will be associated with the map surround. If the default value of None is used, it can be changed at a later time.

(デフォルト値は次のとおりです None)

MapFrame
style_item

An optional reference to a StyleItem value. It must match the mapsuround_type input parameter. If a style_item value is not provided, a default style will be applied.

String
name

An optional string that represents the name of the new MapSurroundElement. If a name is not provided, the default name value will follow the automatic sequencing nomenclature, for example, North Arrow, North Arrow 1, North Arrow 2, and so on.

String
戻り値
データ タイプ説明
MapSurroundElement

Returns a reference to the new MapSurroundElement or LegendElement object.

If the element is created using a point geometry, the point location will represent the anchor position and there will be a default size. Later you can resize the element using the elementWidth and elementHeight properties.

This method returns a reference to a new MapSurroundElement or LegendElement class. The default anchor position is dependent on the map surround type but can be changed after the new element is added to the layout using the setAnchor method.

Refer to the MapSurroundElement or LegendElement class help topics for more information and code samples.

createSpatialMapSeries (mapframe, index_layer, name_field, {sort_field})
パラメーター説明データ タイプ
mapframe

A MapFrame object that has an associated map that includes the index layer needed for creating the spatial map series pages.

MapFrame
index_layer

The index Layer object needed for the extents and attribute information for each page.

(デフォルト値は次のとおりです None)

Layer
name_field

The field name of the field used to control the name of each page in the map series. Ideally, all field values are unique so each page can be uniquely identified.

String
sort_field

The name of the field that will be used to sort the map series pages.

String
戻り値
データ タイプ説明
MapSeries

Returns a reference to the new MapSeries object.

A map series page is created for each feature in the index layer. See the MapSeries help topic for more information and code samples.

createTableFrameElement (geometry, {mapframe}, {table}, {fields}, {style_item}, {name})
パラメーター説明データ タイプ
geometry

A Point or a rectangular Polygon object using layout page units.

Object
mapframe

The MapFrame element that will be associated with the table frame element. If the default value of None is used, it can be changed at a later time using the mapframe property on the TableFrameElement class.

(デフォルト値は次のとおりです None)

MapFrame
table
[table,...]

The Layer or Table object associated with the table frame element. If the default value of None is used, it can be changed at a later time using the table property on the TableFrameElement class.

(デフォルト値は次のとおりです None)

Object
fields

A list of strings that represent the table field names to display in the table frame. If the default value of None is used, it can be changed at a later time using the fields property on the TableFrameElement class.

String
style_item

An optional reference to a StyleItem value. When using the listStyleItems method on the ArcGISProject class, you must use theTABLE_FRAME keyword for the style_class parameter. If a style_item value is not provided, a default style will be applied.

String
name

An optional string that represents the name of the new table frame element. If no name is provided, the default name value will follow the automatic sequencing nomenclature, for example, Table Frame, Table Frame 1, Table Frame 2, and so on.

String
戻り値
データ タイプ説明
Object

Returns a reference to the new TableFrameElement object.

If the element is created using a point geometry, the point location will represent the anchor position and the default size will be applied. You can resize the TableFrameElement object later using the elementWidth and elementHeight properties. The direction the element expands or reduces is based on the anchor position.

This method returns a reference to a new TableFrameElement class. Refer to the TableFrameElement class help topic for more information and code samples.

deleteElement (element)
パラメーター説明データ タイプ
element

An object that represents a layout element to be deleted.

Object

The item is permanently deleted from the layout. Deleting an element may have an impact on other items. For example, if you delete a map frame that is referenced by other map surrounds, those elements will be affected. To delete multiple elements, iterate through a specified list and delete one at a time.

注意:

If you are iterating through all elements, you must delete group elements in reverse order otherwise if you delete a parent group element and then attempt to delete a child group element, an error will occur because the reference to the child no longer exists.

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}, {convert_markers})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです BEST)

String
compress_vector_graphics

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

(デフォルト値は次のとおりです 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.
  • JPEG2000Offers higher quality compression with smaller file size than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです True)

Boolean
embed_color_profile

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

(デフォルト値は次のとおりです True)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです False)

Boolean
keep_layout_background

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

(デフォルト値は次のとおりです False)

Boolean
convert_markers

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(デフォルト値は次のとおりです False)

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})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです NONE)

String
embed_color_profile

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

(デフォルト値は次のとおりです True)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです 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}, {convert_markers})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです False)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです False)

Boolean
convert_markers

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(デフォルト値は次のとおりです 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}, {convert_markers})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです False)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです False)

Boolean
convert_markers

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(デフォルト値は次のとおりです 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})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです 8-BIT_ADAPTIVE_PALETTE)

String
clip_to_elements

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

(デフォルト値は次のとおりです 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})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 80)

Integer
embed_color_profile

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

(デフォルト値は次のとおりです True)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです 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)
パラメーター説明データ タイプ
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}, {keep_layout_background}, {convert_markers}, {simulate_overprint})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです BEST)

String
compress_vector_graphics

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

(デフォルト値は次のとおりです 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.
  • JPEG2000Offers higher quality compression with smaller file size than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです LAYERS_ONLY)

String
georef_info

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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 80)

Integer
clip_to_elements

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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです False)

Boolean
embed_color_profile

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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです False)

Boolean
keep_layout_background

If set to True, the white background will be included in the export.

(デフォルト値は次のとおりです True)

Boolean
convert_markers

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(デフォルト値は次のとおりです False)

Boolean
simulate_overprint

Sometimes called soft proofing, simulating overprinting shows a representation of how overlapping areas of ink will appear when printed on a page. You set up overprinting on symbol layers.

(デフォルト値は次のとおりです 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})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです 32-BIT_WITH_ALPHA)

String
transparent_background

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

(デフォルト値は次のとおりです False)

Boolean
embed_color_profile

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

(デフォルト値は次のとおりです True)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです 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}, {convert_markers})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 96)

Integer
compress_to_svgz

If set to True, the output is compressed.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです False)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです False)

Boolean
convert_markers

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(デフォルト値は次のとおりです 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})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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

(デフォルト値は次のとおりです 32-BIT_WITH_ALPHA)

String
transparent_background

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

(デフォルト値は次のとおりです False)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです 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})
パラメーター説明データ タイプ
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).

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 80)

Integer
transparent_background

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

(デフォルト値は次のとおりです False)

Boolean
embed_color_profile

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

(デフォルト値は次のとおりです True)

Boolean
clip_to_elements

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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです False)

Boolean
georef_mapframe

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

(デフォルト値は次のとおりです 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)
パラメーター説明データ タイプ
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})
パラメーター説明データ タイプ
element_type

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

(デフォルト値は次のとおりです 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.

(デフォルト値は次のとおりです None)

String
戻り値
データ タイプ説明
List

A Python list of page layout elements. The types of objects that can be returned are GraphicElement, GroupElement, LegendElement, MapFrame, MapsurroundElement, PictureElement, TableFrameElement 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 in None or by including the parameter name for all parameters that follow the skipped parameter. For example


elm = lyt.listElements(None, "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.

注意:

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)
パラメーター説明データ タイプ
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.

コードのサンプル

Layout example 1

The following script iterates through all layouts in the current project and prints basic information about each layout including name, page size and units, number of map frames, map frame names, and the total number of layout elements.

aprx = arcpy.mp.ArcGISProject('CURRENT')
print(f'Total Project Layout Count: {str(len(aprx.listLayouts()))} \n')
for lyt in aprx.listLayouts():
    print(f'Layout Name: {lyt.name}')
    print(f'    Width x height: {lyt.pageWidth} x {lyt.pageHeight} units are {lyt.pageUnits}')
    print(f'    MapFrame count: {str(len(lyt.listElements("MapFrame_Element")))}')
    for mf in lyt.listElements("MapFrame_Element"):
        if len(lyt.listElements("MapFrame_Element")) > 0:
            print(f'        MapFrame name: {mf.name}')
    print(f'    Total element count: {str(len(lyt.listElements()))} \n')
Layout example 2

The following script iterates through a list of layout names and exports each layout to PDF two times. The first export uses the default settings for exportToPDF. The second export produces a much smaller output file because the resolution, image_quality, and output_as_image parameters are set accordingly.

import arcpy, os
prjPath = r'C:\Projects\YosemiteNP'
p = arcpy.mp.ArcGISProject(os.path.join(prjPath, 'Yosemite.aprx'))

layoutNames = ['Main Attractions', 'Scenic Views']
for name in layoutNames:
    lyt = p.listLayouts(name)[0]
    #export to PDF - default settings
    lyt.exportToPDF(os.path.join(prjPath, 'Output', name + '_defaults.pdf'))
    #export to PDF - smaller file size
    lyt.exportToPDF(os.path.join(prjPath, 'Output', name + '_small.pdf'), 100, 
                    image_quality = 3,
                    output_as_image = True)
Layout example 3

The following script creates a map and layout. It also creates a map frame, north arrow, and scale bar in the layout. A rectangle helper function is included for making the geometries needed for the map frame and scale bar. Finally, it ensures that the new layout is opened and activated in the application.

def MakeRec_LL(llx, lly, w, h):
    xyRecList = [[llx, lly], [llx, lly+h], [llx+w,lly+h], [llx+w,lly], [llx,lly]]
    array = arcpy.Array([arcpy.Point(*coords) for coords in xyRecList])
    rec = arcpy.Polygon(array)
    return rec

p = arcpy.mp.ArcGISProject('current')

#Create a new map and layout
m = p.createMap('New Map', 'MAP')
lyt = p.createLayout(8.5, 11, 'INCH')

#Create a map frame
mf = lyt.createMapFrame(MakeRec_LL(0.5,5.5,7.5,5), m, "New Map Frame")

#Create a north arrow
naStyle = p.listStyleItems('ArcGIS 2D', 'North_Arrow', 'Compass North 1')[0]
na = lyt.createMapSurroundElement(arcpy.Point(7,7), 'North_Arrow', mf,
                                      naStyle, "Compass North Arrow")
na.elementWidth = 0.5  

#Create a scale bar
sbName = 'Double Alternating Scale Bar 1 Metric'
sbStyle = p.listStyleItems('ArcGIS 2D', 'Scale_bar', sbName)[0]
sbEnv = MakeRec_LL(0.5, 5.5, 2.5, 0.5)
sb = lyt.createMapSurroundElement(sbEnv, 'Scale_bar', mf, sbStyle, 'New Scale Bar')

#Close all view and open and active the layout view
p.closeViews()
lyt.openView()
Layout example 4

The following script shows different ways to use deleteElement. Note that to remove group elements that may exist inside of other group elements, you must delete group elements in opposite order because you must delete the child elements before the parent.

p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts('Layout')[0]

#Delete one element by name
elm = lyt.listElement('GRAPHIC_ELEMENT', 'Point')[0]
lyt.deleteElement(elm)

#Delete all the group elements and their children in reverse order
for elm in reversed(lyt.listElements('GROUP_ELEMENT')):
    lyt.deleteElement(elm)

#Delete remaining elements
for elm in lyt.listElements():
    lyt.deleteElement(elm)
Layout example 5

The following script demonstrates how to use Python CIM Access to add guides to a layout. It creates four new guides 0.5 inches from the edges of the layout.

#CAUTION - this script will remove any existing guides

p = arcpy.mp.ArcGISProject('CURRENT')

for lyt in p.listLayouts(): 
    lyt_cim = lyt.getDefinition('V3')

    newGuides = []

    #Bottom horizontal guide
    botHorz = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V3')
    botHorz.position = 0.5
    botHorz.orientation = 'Horizontal'
    newGuides.append(botHorz)

    #Top horizontal guide
    topHorz = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V3')
    topHorz.position = lyt.pageHeight - 0.5
    topHorz.orientation = 'Horizontal'
    newGuides.append(topHorz)

    #Left vertical guide
    leftVert = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V3')
    leftVert.position = 0.5
    leftVert.orientation = 'Vertical'
    newGuides.append(leftVert)

    #Right vertical guide
    rightVert = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V3')
    rightVert.position = lyt.pageWidth - 0.5
    rightVert.orientation = 'Vertical'
    newGuides.append(rightVert)

    #Add guides and make sure they are turned on
    lyt_cim.page.guides = newGuides
    lyt_cim.page.showGuides = True

    #Set back to layer
    lyt.setDefinition(lyt_cim)