MapFrame

摘要

MapFrame 对象是一个布局元素,用于显示地图的内容。 它还用于访问布局大小、在布局上的位置、基本导航方法以及导出选项。

说明

MapFrame 是一个布局元素,用于显示添加到地图的地理信息。 Layout 对象上的 listElements 方法用于返回布局元素的 Python 列表。 要仅返回仅地图框列表,将 MAPFRAME_ELEMENT 常量用于 element_type 参数。 还可以使用 wildcard 对基于元素 name 的搜索进行进一步优化。

Layout 类上的 createMapFrame 方法还将返回地图框引用。

在引用 MapFrame 后,可通过属性和方法执行不同的操作。 首先,可使用基本属性控制地图框在布局上的大小、定位和可见性。 其次,可使用 panToExtentzoomToAllLayerszoomToBookmark 等诸多导航方法修改在地图框中显示的感兴趣区。 再次,可使用 map 属性更改或访问相关地图。 可在此直接管理底图中的图层、表和底图,以及访问地图的照相机信息,以进一步修改感兴趣区。 可切换尺寸相同或不同的地图。 最后,可使用各种导出方法将地图框导出为不同的导出格式。

提示:

与尝试在应用程序外部导出 MapView 相比,在布局上导出 MapFrame 时生成的结果更一致。 MapView 的导出限制为地图视图仅使用在应用程序外部运行的 Python 脚本。 这是因为仅当打开应用程序及其视图窗格时才能获悉窗口和感兴趣区大小。MapFrame 导出将所有大小调整信息保留在元素中,因此在应用程序内部运行或在应用程序外部作为独立脚本运行的脚本将生成相同的导出结果。

属性

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

返回表示当前锚点位置的以下字符串值之一。 要更改值,请使用 setAnchor 方法。

  • BOTTOM_LEFT_CORNER左下角位置
  • BOTTOM_MID_POINT底部中央位置
  • BOTTOM_RIGHT_CORNER右下角位置
  • CENTER_POINT中央位置
  • LEFT_MID_POINT左侧中央位置
  • RIGHT_MID_POINT右侧中央位置
  • TOP_LEFT_CORNER左上角位置
  • TOP_MID_POINT顶部中央位置
  • TOP_RIGHT_CORNER右上角位置
String
camera
(可读写)

相机用于控制数据在地图框中显示的位置和查看位置。

Camera
elementHeight
(可读写)

页面布局上的地图框高度。 分配或报告的单位为页面单位。

Double
elementPositionX
(可读写)

地图框的锚点位置对应的 x 位置。 分配或报告的单位为页面单位。

Double
elementPositionY
(可读写)

地图框的锚点位置对应的 y 位置。 分配或报告的单位为页面单位。

Double
elementRotation
(可读写)

地图框的旋转角度(以度为单位)。 正值将使方向顺时针旋转,负值将使方向逆时针旋转。 这是地图框在布局上的角度,不是数据的旋转。 使用 camera 上的 heading 属性旋转数据。

Double
elementWidth
(可读写)

页面布局上的地图框宽度。 分配或报告的单位为页面单位。

Double
locked
(可读写)

设置为 True 时,无法在布局视图中以图形方式选择元素。

Boolean
map
(可读写)

在地图框中显示的地图

Map
name
(可读写)

元素的名称。 必须确保所有元素均具有唯一名称,因为这样可以通过在 Layout 对象的 listElements 函数中使用 wildcard 参数以唯一方式引用这些元素。

String
time
(只读)

如果启用时间的图层存在于地图框中,则返回 MapTime 对象。 如果地图框不包含启用时间的图层,则返回值 None

提示:

Layer 类中的 enableTime 方法允许您针对具有时间信息的图层启用时间,从而可以访问 LayerTimeMapTime 属性。

MapTime
type
(只读)

返回值 MAPFRAME_ELEMENT

String
visible
(可读写)

如果地图框在布局上可见,则返回 True。 打印或导出之前,您可以打开和关闭元素的可见性,而不必从页面移除不需要的对象。

Boolean

方法概述

方法说明
createBookmark ({name}, {description})

createBookmark 方法可使用当前相机设置为与地图框相关联的地图创建书签

exportToAIX (out_aix, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {convert_markers})

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

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

将 MapFrame 导出为 Microsoft Windows 位图 (BMP) 格式文件。

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

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

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

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

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

将 MapFrame 导出为图形交换格式 (GIF) 文件。

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

将 MapFrame 导出为联合图像专家组 (JPEG) 格式。

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

将 MapFrame 导出为便携式文档格式 (PDF) 文件。

exportToPNG (out_png, {resolution}, {world_file}, {color_mode}, {embed_color_profile})

用于将 MapFrame 导出为便携式网络图形 (PNG) 格式。

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

将 MapFrame 导出为可伸缩矢量图形 (SVG) 格式文件。

exportToTGA (out_tga, {resolution}, {world_file}, {color_mode})

将 MapFrame 导出为 Truevision 图形适配器 (TGA) 格式文件。

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

用于将 MapFrame 导出为标记图像文件格式 (TIFF)。

getDefinition (cim_version)

用于返回地图框元素的 CIM 定义。

getLayerExtent (layer, {selection_only}, {symbolized_extent})

返回图层中所有要素或仅仅所选要素的图层范围。

panToExtent (extent)

使用新 Extent 对象可平移和居中 MapFrame,而无需更改地图框的比例。

setAnchor (anchor)

setAnchor 方法可控制 MapFrame 元素的锚点位置。

setDefinition (definition_object)

设置地图框元素的 CIM 定义。

zoomToAllLayers ({selection_only}, {symbolized_extent})

修改 MapFrame 视图以便与所有图层或地图中所选图层的范围相匹配。

zoomToBookmark (bookmark)

修改 MapFrame 视图以便与通过空间书签存储的视图信息相匹配。

方法

createBookmark ({name}, {description})
参数说明数据类型
name

An string that represents the name of the new bookmark. If a name is not provided, the default name will follow the sequencing nomenclature, for example, Bookmark, Bookmark [1], Bookmark [2].

String
description

A string that represents the bookmark's description. If not specified, the value is an empty string.

String
返回值
数据类型说明
Bookmark

书签对象。

此方法会返回对新 Bookmark 类的参考。 请参阅 Bookmark签 类帮助主题中的代码示例。

exportToAIX (out_aix, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {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
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 是从 ArcGIS 导出的 Adobe Illustrator Exchange 文件,可在 ArcGIS Maps for Adobe Creative Cloud 插件中使用。 与插件配合使用时,矢量地图和栅格地图内容将转换为可编辑的 Artwork 图层,以改善 Adobe Illustrator 中的编辑体验。 在 Illustrator 中打开 AIX 后,可用于高端图形设计或地图最后处理工作流,并可在其他 Adobe Creative Cloud 应用程序之间进行迁移。

exportToBMP (out_bmp, {resolution}, {world_file}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile})
参数说明数据类型
out_bmp

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
world_file

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information.

(默认值为 False)

Boolean
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

BMP 文件属于本地 Windows 栅格图像。 BMP 文件可以使用多个位深度存储像素数据。 BMP 图像的大小通常比 JPEG 或 PNG 等其他格式的图像大很多。

exportToEMF (out_emf, {resolution}, {image_quality}, {output_as_image}, {convert_markers})
参数说明数据类型
out_emf

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

exportToEPS (out_eps, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {convert_markers})
参数说明数据类型
out_eps

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

exportToGIF (out_gif, {resolution}, {world_file}, {gif_color_mode})
参数说明数据类型
out_gif

A string that represents the system 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
world_file

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information.

(默认值为 False)

Boolean
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

GIF 文件属于 Web 中使用的旧的栅格格式。 GIF 无法显示 256 种以上的颜色(每像素 8 位),并且使用的是可选的无损 RLE 压缩或 LZW 压缩方法,因此此类文件的大小比其他格式的文件要小。 类似 PNG,GIF 文件还可定义透明颜色。 GIF 在生成时,还将同时生成一个坐标文件,可用作地理配准栅格数据

exportToJPEG (out_jpg, {resolution}, {world_file}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile})
参数说明数据类型
out_jpg

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
world_file

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information. If you export a 3D map frame, this parameter will be ignored regardless of the setting because world files are not applicable to 3D views.

(默认值为 False)

Boolean
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. For 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

JPEG 文件属于经过压缩的图像文件。 它支持 24 位颜色并且是 Web 上流行的使用格式,因为 JPEG 文件大小通常要比许多其他图像格式小很多。 但是,JPEG 压缩算法会有损质量,多数地图图像中都不推荐使用,因为线绘图以及文本或图标图形会因压缩产生的伪影而变得模糊。 因此,通常 PNG 格式才是地图图像的首选。 在生成 JPEG 文件的同时,还将生成一个坐标文件,可用作地理配准栅格数据。

exportToPDF (out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {output_as_image}, {embed_color_profile}, {convert_markers}, {simulate_overprint})
参数说明数据类型
out_pdf

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).

(默认值为 300)

Integer
image_quality

A string that defines the output image quality and 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 the compression of vector and text portions of the output file. Image compression is defined separately.

(默认值为 True)

Boolean
image_compression

A string that defines 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 controls the inclusion of PDF layers and PDF object data (attributes) in the export file.

  • LAYERS_ONLYExport PDF layers only.
  • LAYERS_AND_ATTRIBUTESExport PDF layers and feature attributes.
  • NONENo setting is applied.

(默认值为 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 the 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 70 through 90.

(默认值为 80)

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

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

exportToPNG (out_png, {resolution}, {world_file}, {color_mode}, {embed_color_profile})
参数说明数据类型
out_png

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
world_file

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information. If you export a 3D map frame, this parameter will be ignored regardless of the setting because world files are not applicable to 3D views.

(默认值为 False)

Boolean
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
embed_color_profile

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

(默认值为 True)

Boolean

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

exportToSVG (out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {convert_markers})
参数说明数据类型
out_svg

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

exportToTGA (out_tga, {resolution}, {world_file}, {color_mode})
参数说明数据类型
out_tga

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
world_file

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information.

(默认值为 False)

Boolean
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

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

exportToTIFF (out_tif, {resolution}, {world_file}, {color_mode}, {tiff_compression}, {geoTIFF_tags}, {jpeg_compression_quality}, {embed_color_profile})
参数说明数据类型
out_tif

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
world_file

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information. If you export a 3D map frame, this parameter will be ignored regardless of the setting because world files are not applicable to 3D views.

(默认值为 False)

Boolean
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
geoTIFF_tags

If set to True, georeferencing tags are included in the structure of the TIFF export file. The tags contain pixel scale information and real-world coordinate information. These tags can be read by applications that support GeoTIFF format.

(默认值为 False)

Boolean
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
embed_color_profile

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

(默认值为 True)

Boolean

TIFF 文件最适合导入图像编辑应用程序,同时它也属于一种常用的 GIS 栅格数据格式。 但是却无法通过 Web 浏览器在本地查看这些文件。 TIFF 文件还支持在 GeoTIFF 标签中或在单独坐标文件中存储地理配准信息,以便用作栅格数据。

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

A string that represents the major version of the CIM that will be used.

  • V2The 2.x version of the CIM will be used.
  • V3The 3.x version of the CIM will be used.
String
返回值
数据类型说明
Object

返回 MapFrame 值的 CIM 定义。

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

getLayerExtent (layer, {selection_only}, {symbolized_extent})
参数说明数据类型
layer

引用 Layer 对象。

Layer
selection_only

如果为 True,将返回选定要素的范围;如果为 False,将返回所有要素的范围。

(默认值为 True)

Boolean
symbolized_extent

如果值为 True,将返回图层的符号化范围;否则将返回几何范围。符号化范围会将符号覆盖的区域考虑在内,因此该区域不会被数据框边界切掉。

(默认值为 True)

Boolean
返回值
数据类型说明
Extent

地理处理 Extent 对象。

getLayerExtent 方法将支持图层定义查询,因此如果查询了要素子集,则将只返回这些要素的范围。如果未选择要素,则将返回图层的范围。

panToExtent (extent)
参数说明数据类型
extent

地理处理 Extent 对象。

Extent

此方法尤为适合 MapFrame 比例未变而位置发生了变化的情况。无需设置范围以及每次都重置比例,panToExtent 保持比例不变,然后使当前地图框在新范围中居中。

setAnchor (anchor)
参数说明数据类型
anchor

A string that specifies the location of the anchor position.

  • BOTTOM_LEFT_CORNERThe anchor will be set at the bottom left corner position.
  • BOTTOM_MID_POINTThe anchor will be set at the bottom center position.
  • BOTTOM_RIGHT_CORNERThe anchor will be set at the bottom right corner position.
  • CENTER_POINTThe anchor will be set at the center position.
  • LEFT_MID_POINTThe anchor will be set at the left center position.
  • RIGHT_MID_POINTThe anchor will be set at the right center position.
  • TOP_LEFT_CORNERThe anchor will be set at the top left corner position.
  • TOP_MID_POINTThe anchor will be set at the top center position.
  • TOP_RIGHT_CORNERThe anchor will be set at the top right corner position.
String

设置锚点位置非常有用,因为您可以控制元素在调整大小时的展开方式。 例如,地图框元素的默认锚点位置为 BOTTOM_LEFT_CORNER。 如果将锚点位置更改为 TOP_RIGHT_CORNER,则更改 elementHeight 将使元素向下扩展,而非向上扩展;更改 elementWidth 将使元素向左扩展。

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

A modified CIM definition object originally retrieved using getDefinition.

Object

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

zoomToAllLayers ({selection_only}, {symbolized_extent})
参数说明数据类型
selection_only

如果为 True,将根据选定要素设置范围;如果为 False,将为地图中的所有要素设置范围。

(默认值为 True)

Boolean
symbolized_extent

如果值为 True,将返回图层的符号化范围;否则将返回几何范围。符号化范围会将符号覆盖的区域考虑在内,因此该区域不会被地图框边界切掉。

(默认值为 True)

Boolean

如果对含有全局或本地场景的 MapFrame 使用了 zoomToAllLayers,则将生成平面视图。

zoomToBookmark (bookmark)
参数说明数据类型
bookmark

引用 Bookmark 对象。

Bookmark

如果对引用了 2D 地图MapFrame 使用了 3D 书签(反之亦然),则将生成平面试图。

代码示例

MapFrame 示例 1

以下脚本通过各种方式设置地图框范围并将每个结果导出为 PDF。 它首先使用要素选择设置范围。 接下来,它会缩放到单一图层范围并应用轻微缓冲区。 最后,它会执行相同的操作,但是会缩放到每个要素的范围。

import arcpy, os
aprx = arcpy.mp.ArcGISProject(r'C:\Projects\GreatLakes\GreatLakes.aprx')

m = aprx.listMaps('Map')[0]
lyr = m.listLayers('GreatLakes')[0]
lyt = aprx.listLayouts('Layout')[0]
mf = lyt.listElements('mapframe_element', 'Map Frame')[0]

#Zoom to ALL selected features and export to PDF
arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION', "NAME = 'Lake Superior'")
mf.zoomToAllLayers(True)
mf.exportToPDF(r'C:\Projects\GreatLakes\Selection.pdf')
arcpy.SelectLayerByAttribute_management(lyr, 'CLEAR_SELECTION')

#Set the map frame extent to the extent of a layer and export to PDF
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))
mf.camera.scale = mf.camera.scale * 1.1 #add a slight buffer
mf.exportToPDF(r'C:\Projects\GreatLakes\GreatLakesExtent.pdf')

#Set the map frame extent based on eash feature in a layer and export to PDF
for row in arcpy.da.SearchCursor(lyr, ['SHAPE@', 'NAME']):
    mf.camera.setExtent(row[0].extent)
    mf.camera.scale = mf.camera.scale * 1.1 #add a slight buffer
    mf.exportToPDF(os.path.join(r'C:\Projects\GreatLakes', f'{row[1]}.pdf'))
MapFrame 示例 2

以下脚本会将 MXD 和 3DD 文档导入到空白工程中。 在引用适当的元素后,它会将每个 2D 插图地图更改为 3D 场景并将适当的书签应用于每个地图框。 最后,整个布局将导出为 PDF。

import arcpy
p = arcpy.mp.ArcGISProject(r'C:\Projects\Blank.aprx')

#Import documents into project
p.importDocument(r'C:\Projects\YosemiteNP\Documents\Yosemite.mxd')
p.importDocument(r'C:\Projects\YosemiteNP\Documents\Yosemite_3DViews.3dd')

#Reference maps
scene = p.listMaps('Globe layers')[0]

#Reference Layout and map frames
lyt = p.listLayouts()[0]
mainMF = lyt.listElements('MapFrame_Element', 'Yosemite National Park*')[0]
inset1MF = lyt.listElements('MapFrame_Element', 'Inset1*')[0]
inset2MF = lyt.listElements('MapFrame_Element', 'Inset2*')[0]

#Convert imported 2D insets into 3D views and zoom to bookmarks
mainMF.zoomToBookmark(mainMF.map.listBookmarks('Yosemite Valley')[0])

inset1MF.map = scene
inset1MF.zoomToBookmark(inset1MF.map.listBookmarks('Yosemite Yalley (looking East)')[0])

inset2MF.map = scene
inset2MF.zoomToBookmark(inset2MF.map.listBookmarks('Yosemite Valley (looking West)')[0])

#Export the resulting imported layout and changes to PDF
lyt.exportToPDF(r'C:\Projects\YosemiteNP\Example2_Export.pdf')
MapFrame 示例 3

以下脚本演示了如何使用几何和几何创建地图框。

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

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

#Create a new map frame using a polygon geometry
envCoordList = [[0.5, 5.75], [0.5, 10.5], [8, 10.5], [8, 5.75], [0.5, 5.75]]
envArray = arcpy.Array([arcpy.Point(*coords) for coords in envCoordList])
mf1 = lyt.createMapFrame(arcpy.Polygon(envArray), m, 'New MF - Poly')

#Create a new bookmark set to the map frame's default extent
bkmk = mf1.createBookmark('Default Extent', "The map's default extent")
bkmk.updateThumbnail()

#Create a new map frame using a point geometry
mf2 = lyt.createMapFrame(arcpy.Point(0.5,0.5), m, 'New MF - Point')
mf2.elementWidth = 7.5
mf2.elementHeight = 4.75
MapFrame 示例 4

以下脚本演示了如何使用 Python CIM 访问来修改布局中每个地图框的边界符号系统。

p = arcpy.mp.ArcGISProject('CURRENT')
lyt = p.listLayouts('Layout')[0]
lyt_cim = lyt.getDefinition('V3')
for elm in lyt_cim.elements:
    if type(elm).__name__ == 'CIMMapFrame':
        if elm.graphicFrame.borderSymbol.symbol.symbolLayers:
            sym = elm.graphicFrame.borderSymbol.symbol.symbolLayers[0]
            sym.width = 5
            sym.color.values = [255, 0, 0, 100]
        else:
            print(elm.name + ' has NO symbol layers')            
lyt.setDefinition(lyt_cim)