Layout

摘要

Layout 对象将引用 ArcGIS Pro 工程 (.aprx) 中的单个页面布局。可用于访问常见属性(如页面大小)和多个不同的导出方法。

说明

ArcGIS Pro 工程可包含多个页面布局。可使用 ArcGISProject 对象的 listLayouts 方法访问布局,这将返回 Layout 对象的 Python 列表。有必要确保每个布局均具有唯一名称,因为这样可以通过 name 轻松引用特定页面布局。

listElements 方法可用于访问页面布局上的所有元素:GraphicElementLegendElementMapFrameElementMapSurroundElementPictureElementTextElement

通过 Layout 对象可访问多个 exportTo 方法。如果想要导出整个页面布局,可使用 Layout 导出方法。如果只想要导出单个地图框的内容,还可使用 MapFrame 类中提供的相似的一组导出方法。

布局可以包括单个 MapSeries。如果 mapSeries 属性返回 None,则表明尚未在布局中创建地图系列。在尝试操作地图系列属性之前,应先检查地图系列是否为 enabled

属性

属性说明数据类型
mapSeries
(只读)

如果启用了空间地图系列,则将返回 MapSeries 对象。 如果地图系列不存在或者其为书签地图系列,则将返回 NoneType

MapSeries
metadata
(可读写)

获取或设置布局的元数据类信息。

注:
设置元数据取决于 isReadOnly 属性值。

Metadata
name
(可读写)

布局的名称。 有必要确保所有布局都具有唯一的名称,因为这样便可通过这些唯一名称轻松对其进行引用。

String
pageHeight
(可读写)

布局的页面高度取决于当前的 pageUnits

Double
pageUnits
(可读写)

布局的页面单位。 下面是设置页面单位时可使用的有效字符串列表。

  • CENTIMETER厘米
  • INCH英寸
  • MILLIMETER毫米
  • POINT
String
pageWidth
(可读写)

布局的页面宽度取决于当前的 pageUnits

Double
URI
(只读)

布局的统一资源指示符。 这是项目中布局的唯一标识符,使用 Python CIM 访问时有时需要它。 添加布局并建立 URI 后,该值不会随时间变化。 例如,如果您修改布局的名称,则 URI 不会更改。

String

方法概述

方法说明
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})

将布局导出为 Adobe Illustrator Exchange (AIX) 格式。 可在 ArcGIS Maps for Adobe Creative Cloud 扩展模块或 Adobe Illustrator 中使用 AIX 文件。

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

将布局导出为 Microsoft Windows 位图格式 (BMP)。

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

将布局导出为增强型图元文件 (EMF) 格式。

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

将布局导出为封装 PostScript (EPS) 格式文件。

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

将布局导出为图形交换格式 (GIF)。

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

将布局导出为联合图像专家组 (JPEG) 格式文件。

exportToPAGX (out_pagx)

将布局导出至页面文件 (.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})

用于将布局导出为便携文档格式 (PDF)。

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

将布局导出为便携式网络图形 (PNG) 格式文件。

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

将布局导出为可伸缩矢量图形 (SVG) 格式。

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

将布局导出为 Truevision 图形适配器 (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})

将布局导出为标记图像文件格式 (TIFF) 文件。

getDefinition (cim_version)

获取布局的 CIM 定义。

listElements ({element_type}, {wildcard})

返回 Layout 对象包含的页面布局元素的 Python 列表。

openView ()

在应用程序中打开并激活一个新的布局视图窗格。

setDefinition (definition_object)

设置布局的 CIM 定义。

方法

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})
参数说明数据类型
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.
  • 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.

(默认值为 True)

Boolean

AIX 是从 ArcGIS 导出的 Adobe Illustrator Exchange 文件,可在 ArcGIS Maps for Adobe Creative Cloud 插件中使用。 与插件配合使用时,矢量地图和栅格地图内容将转换为可编辑的 Artwork 图层,以改善 Adobe Illustrator 中的编辑体验。 在 Illustrator 中打开 AIX 后,可用于高端图形设计或地图最后处理工作流,并可在其他 Adobe Creative Cloud 应用程序之间进行迁移。

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 文件属于本地 Windows 栅格图像。 BMP 文件可以使用多个位深度存储像素数据。 BMP 图像的大小通常比 JPEG 或 PNG 等格式的图像大很多。

exportToEMF (out_emf, {resolution}, {image_quality}, {output_as_image}, {clip_to_elements})
参数说明数据类型
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

EMF 文件属于本地 Windows 图形文件,其中既包含矢量数据又包含栅格数据。 这些文件非常适合于嵌入 Windows 文档,因为 EMF 的矢量部分可以调整大小,而又不会降低质量。 但是,由于 EMF 不支持字体嵌入并且属于 Windows 专用格式,因此并不常用作用户之间的交换格式。

exportToEPS (out_eps, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})
参数说明数据类型
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

EPS 文件将通过 PostScript 页面描述语言描述矢量对象和栅格对象。 PostScript 是高端图形文件、制图和打印的出版行业标准。 许多绘图应用程序中都可编辑 EPS 文件,也可将此类文件作为图形置于大多数页面布局应用程序中。 EPS 文件支持字体嵌入,因此即使用户尚未安装 Esri 字体也可以查看正确的符号。

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_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale

(默认值为 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.

(默认值为 False)

Boolean

GIF 文件属于 Web 中使用的旧的栅格格式。 GIF 文件无法显示 256 种以上的颜色(每像素 8 位),并且使用的是可选的无损压缩,因此,该类文件的大小比其他格式的文件要小。

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 文件属于经过压缩的图像文件。 它支持 24 位颜色并且是 Web 上流行的使用格式,因为 JPEG 文件大小通常要比许多其他图像格式小很多。 但是,JPEG 压缩算法会有损质量,多数地图图像中都不推荐使用,因为线绘图以及文本或图标图形会因压缩产生的伪影而变得模糊。 因此,通常 PNG 格式才是地图图像的首选。

exportToPAGX (out_pagx)
参数说明数据类型
out_pagx

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

String

如果您希望将布局保存至页面文件,以供日后使用 ArcGISProject importDocument 方法将其导入到工程中,则此方法将非常有用。

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})
参数说明数据类型
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.
  • 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

PDF 文件可跨不同平台实现一致的查看和打印效果。 它们常用于在 Web 上分发文档,并且此格式现在属于文档交换的 ISO 官方标准。 PDF 文件在许多图形应用程序中均可编辑,并会保留地图的地理配准信息、注记、标注和要素属性数据。 PDF 导出支持字体嵌入,即使在用户尚未安装 Esri 字体时,也可以正确显示符号系统。

查看 PDFDocument 类以了解更多关于如何管理 PDF 文件的方法,如追加、插入以及设置属性。

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

PNG 文件属于通用型栅格格式文件,可在各种 Web 浏览器上显示并且还可插入其他文档。 它支持高位深度颜色并使用无损压缩。 对于地图而言,PNG 通常是最佳的栅格格式,因为无损压缩可防止产生 JPEG 格式中的那种压缩伪影,从而使文本和线作业始终清晰可辨。 PNG 文件还可定义透明颜色。

exportToSVG (out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})
参数说明数据类型
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

SVG 是一种基于 XML 的文件格式,专门适用于在 Web 上进行查看。 SVG 可以同时包含矢量信息和栅格信息。 一些 web 浏览器可能需要插件才能查看 SVG 文件。 较早版本的浏览器可能根本无法查看 SVG 文件。 SVG 支持字体嵌入,因此即使用户尚未安装 Esri 字体也可以使用正确符号系统查看导出的 SVG 文件。 也可以选择生成压缩的 SVG 文件。 如果启用此选项,文件扩展名变为 .svgz

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 文件以往用于其他应用程序中的内容(例如,动画游戏的 Image Sprites),许多受欢迎的图形艺术应用程序均可对该文件进行读取和写入。 TGA 格式支持多位深度,包括支持 alpha(透明)的 32 位。

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 文件最适合导入图像编辑应用程序,同时它也属于一种常用的 GIS 栅格数据格式。 但是却无法通过 Web 浏览器在本地查看这些文件。

getDefinition (cim_version)
参数说明数据类型
cim_version

用于表示 CIM 的主要版本的字符串。

String

在版本 2.4 中引入了对其他对象属性的 CIM 级别访问权限。Esri 遵循语义版本规范。这意味着,在允许突破性 API 更改的下一个主要版本(例如,3.0)之前,与 cim_version 搭配使用的值为 V2。发布 3.0 之后,新 V3 选项将可用。如果可能在新版本中引入突破性更改,Python 脚本作者可通过该选项控制执行期间将使用的 CIM 版本。

有关使用 CIM 和示例的详细信息,请参阅 Python CIM 访问

listElements ({element_type}, {wildcard})
参数说明数据类型
element_type

代表用于过滤已返回元素列表的元素类型的字符串。

(默认值为 None)

String
wildcard

通配符基于元素名称且不区分大小写。星号 (*) 和字符的组合可用于帮助限制生成的结果。

(默认值为 None)

String
返回值
数据类型说明
List

页面布局元素的 Python 列表。可以返回的对象类型为 GraphicElementLegendElementMapFrameMapsurroundElementPictureElementTextElement

每个页面元素均具有 name 属性,该属性可在“元素属性”对话框中进行设置。布局作者应负责确保每个页面元素被赋予唯一名称,以便可以唯一标识这些元素。如果两个元素有相同名称,则没有办法确保它就是您要引用的元素。

listElements 方法会将元素组里的元素返回到平面列表。这使您可以方便地搜索和替换文本字符串,例如不必通过组元素结构进行浏览。

可通过传送空字符串或添加所跳过参数后面的所有参数的参数名称跳过 element_type 参数。例如

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

openView ()

如果布局视图尚未打开,或者应用程序中的另一个视图处于活动状态,则此方法将非常有用。 该方法将创建一个缩放至其全图范围的布局视图并将其激活。 在打开新视图之前,要关闭其他现有视图,请使用 ArcGISProject closeViews 方法。

注:

此方法旨在使用脚本工具、Notebook 或 Python 窗口在应用程序中运行。 如果在应用程序之外运行该方法,则其将无效。

setDefinition (definition_object)
参数说明数据类型
definition_object

使用 getDefinition 最初检索的已修改 CIM 定义对象。

Object

有关使用 CIM 和示例的详细信息,请参阅 Python CIM 访问

代码示例

布局示例 1

下面的脚本使用了关键字 current,因此可从 Python 窗口运行此脚本。此脚本打印了工程及其图层中每个地图的名称,以及每个布局的名称及其页面大小。

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})")
布局示例 2

下面的脚本会通过缩放至每个属于名为约塞米蒂国家公园的地图的书签来更新地图框的感兴趣区域,并将结果导出至各个 PDF 文档。

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
布局示例 3

下面的脚本将检查是否存在地图系列,然后将其两个页面导出为 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")