Skip to main content

addGrid

汇总

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

讨论

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

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

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

提示:

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

语法

addGrid()

属性

名称 说明 数据类型

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

方法

addGrid(style_item)

addGrid 方法可使用样式项目将格网或经纬网添加到 MapFrame

名称 说明 数据类型

style_item

The reference to a grid StyleItem object using the listStyleItems method on the ArcGISProject class.

StyleItem

convertGridToFeatures(grid_name, output_geodatabase, {new_grid_name})

MapFrame 格网或经纬线转换为地理数据库要素。

名称 说明 数据类型

grid_name

The name of the grid or graticule the way it appears in the Contents pane.

String

output_geodatabase

The full path to a file geodatabase (*.gdb) or an enterprise geodatabase (*.sde) including the geodatabase name and extension.

String

new_grid_name

(可选)

The new name of the group layer added to the map frame's map that will contain all the resulting feature layers. This value will also be added to the GridName field in each feature class table.

String

createBookmark({name}, {description})

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

名称 说明 数据类型

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

书签 对象。

export(export_format, {display_options})

export 方法可使用指定 export_format 导出 MapFrame

名称 说明 数据类型

export_format

The supported export format objects are: AIXFormat, BMPFormat, EMFFormat, EPSFormat, GIFFormat, JPEGFormat, PDFFormat, PNGFormat, SVGFormat, TGAFormat and TIFFFormat.

Object

display_options

(可选)

The DisplayOptions object includes antialiasing mode options.

Object

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 文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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.

  • BEST—An output image quality resample ratio of 1

  • BETTER—An output image quality resample ratio of 2

  • NORMAL—An output image quality resample ratio of 3

  • FASTER—An output image quality resample ratio of 4

  • FASTEST—An 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.

  • ADAPTIVE—Automatically 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.

  • DEFLATE—A lossless data compression.

  • JPEG—A lossy data compression.

  • JPEG2000—Offers higher quality compression with smaller file size than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • RLE—Run-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

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-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.

  • NONE—Compression is not applied.

  • RLE—Run-length encoded compression.

(默认值为 NONE)

String

embed_color_profile

(可选)

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

(默认值为 True)

Boolean

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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.

  • BEST—An output image quality resample ratio of 1

  • BETTER—An output image quality resample ratio of 2

  • NORMAL—An output image quality resample ratio of 3

  • FASTER—An output image quality resample ratio of 4

  • FASTEST—An 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

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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.

  • DEFLATE—A lossless data compression.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • RLE—Run-length encoded compression.

(默认值为 DEFLATE)

String

image_quality

(可选)

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

  • BEST—An output image quality resample ratio of 1.

  • BETTER—An output image quality resample ratio of 2.

  • NORMAL—An output image quality resample ratio of 3.

  • FASTER—An output image quality resample ratio of 4.

  • FASTEST—An 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

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

(默认值为 8-BIT_ADAPTIVE_PALETTE)

String

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-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

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) 文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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.

  • BEST—An output image quality resample ratio of 1

  • BETTER—An output image quality resample ratio of 2

  • NORMAL—An output image quality resample ratio of 3

  • FASTER—An output image quality resample ratio of 4

  • FASTEST—An 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.

  • ADAPTIVE—Automatically 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.

  • DEFLATE—A lossless data compression.

  • JPEG—A lossy data compression.

  • JPEG2000—Offers higher quality compression with smaller file size than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • RLE—Run-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_ONLY—Export PDF layers only.

  • LAYERS_AND_ATTRIBUTES—Export PDF layers and feature attributes.

  • NONE—No 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

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_png

用于表示输出导出文件的路径和文件名的字符串。

String

resolution

(可选)

用于定义导出文件分辨率的数字,单位为每英寸点数 (dpi)。

(默认值为 96)

Integer

world_file

(可选)

如果设置为 True ,将创建地理配准坐标文件。 文件中包含像素比例信息和真实世界坐标信息。 导出 3D 地图框时,无论设置为何,都将忽略此参数,因为坐标文件不适用于 3D 视图。

(默认值为 False)

Boolean

color_mode

(可选)

该值可指定用于描述颜色的位数。

  • 8-BIT_ADAPTIVE_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-bit true color

  • 32-BIT_WITH_ALPHA—32-bit with alpha

(默认值为 32-BIT_WITH_ALPHA)

String

embed_color_profile

(可选)

如果设置为 True ,则颜色配置文件信息将嵌入在图像的元数据中。

(默认值为 True)

Boolean

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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.

  • BEST—An output image quality resample ratio of 1.

  • BETTER—An output image quality resample ratio of 2.

  • NORMAL—An output image quality resample ratio of 3.

  • FASTER—An output image quality resample ratio of 4.

  • FASTEST—An 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

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-bit true color

  • 32-BIT_WITH_ALPHA—32-bit with alpha

(默认值为 32-BIT_WITH_ALPHA)

String

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

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

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

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_PALETTE—8-bit adaptive palette. Available to RGB and CMYK.

  • 8-BIT_GRAYSCALE—8-bit grayscale. Available to RGB and CMYK.

  • 24-BIT_TRUE_COLOR—24-bit true color. Available only to RGB.

  • 32-BIT_WITH_ALPHA—32-bit with alpha. Available only to RGB.

  • 32-BIT_CMYK_TRUE_COLOR—32-bit CMYK true color. Available only to CMYK.

  • 40-BIT_CMYK_WITH_ALPHA—40-bit CMYK with alpha. Available only to CMYK.

(默认值为 24-BIT_TRUE_COLOR)

String

tiff_compression

(可选)

This value represents a compression scheme.

  • DEFLATE—A lossless data compression.

  • JPEG—JPEG compression.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • PACK_BITS—Pack 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

getDefinition(cim_version)

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

名称 说明 数据类型

cim_version

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

  • V2—The 2.x version of the CIM will be used.

  • V3—The 3.x version of the CIM will be used.

String

返回值

数据类型 说明

Object

返回 MapFrame 值的 CIM 定义。

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

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

名称 说明 数据类型

layer

引用 Layer 对象。

Layer

selection_only

(可选)

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

(默认值为 True)

Boolean

symbolized_extent

(可选)

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

(默认值为 True)

Boolean

返回值

数据类型 说明

Extent

地理处理 Extent 对象。

panToExtent(extent)

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

名称 说明 数据类型

extent

地理处理 Extent 对象。

Extent

removeGrids({wildcard})

removeGrids 方法可从地图框中移除一个或多个格网或经纬网。

名称 说明 数据类型

wildcard

(可选)

A wildcard is based on the grid or graticule name in the Contents pane and is not case sensitive. A combination of asterisks (*) and characters can be used to limit the resulting list.

(默认值为 None)

String

setAnchor(anchor)

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

名称 说明 数据类型

anchor

A string that specifies the location of the anchor position.

  • BOTTOM_LEFT_CORNER—The anchor will be set at the bottom left corner position.

  • BOTTOM_MID_POINT—The anchor will be set at the bottom center position.

  • BOTTOM_RIGHT_CORNER—The anchor will be set at the bottom right corner position.

  • CENTER_POINT—The anchor will be set at the center position.

  • LEFT_MID_POINT—The anchor will be set at the left center position.

  • RIGHT_MID_POINT—The anchor will be set at the right center position.

  • TOP_LEFT_CORNER—The anchor will be set at the top left corner position.

  • TOP_MID_POINT—The anchor will be set at the top center position.

  • TOP_RIGHT_CORNER—The anchor will be set at the top right corner position.

String

setDefinition(definition_object)

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

名称 说明 数据类型

definition_object

A modified CIM definition object originally retrieved using getDefinition.

Object

zoomToAllLayers({selection_only}, {symbolized_extent})

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

名称 说明 数据类型

selection_only

(可选)

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

(默认值为 True)

Boolean

symbolized_extent

(可选)

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

(默认值为 True)

Boolean

zoomToBookmark(bookmark)

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

名称 说明 数据类型

bookmark

引用 Bookmark 对象。

Bookmark

代码示例

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)
pdf = arcpy.mp.CreateExportFormat('PDF', r'C:\Projects\GreatLakes\Selection.pdf')
mf.export(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
pdf.filePath = r'C:\Projects\GreatLakes\GreatLakesExtent.pdf'
mf.export(pdf)

#Set the map frame extent based on each 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
    pdf.filePath = os.path.join(r'C:\Projects\GreatLakes', f'{row[1]}.pdf')
    mf.export(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 Yalley (looking West)')[0])

#Export the resulting imported layout and changes to PDF
pdf = arcpy.mp.CreateExportFormat('PDF', r'C:\Projects\YosemiteNP\Example2_Export.pdf')
lyt.export(pdf)
MapFrame 示例 3

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

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)