addGrid
Краткая информация
Объект MapFrame представляет собой элемент компоновки, который используется для отображения содержимого карты. Он также предоставляет доступ к размеру компоновки, положению в компоновке простым методам навигации и опциям экспорта.
Обсуждение
MapFrame является элементом компоновки, который отображает географическую информацию, добавленную на map. Метод listElements для объекта Layout возвращает список Python элементов компоновки. Чтобы получить список, содержащий только фреймы карты, используйте константу MAPFRAME_ELEMENT для параметра element_type. wildcard также может быть использована для дальнейшей настройки поиска по name элемента.
Метод createMapFrame класса Layout также возвратит ссылку на фрейм карты.
После получения ссылки на MapFrame, свойства и методы позволяют выполнять различные операции. Во-первых, есть базовые свойства, позволяющие управлять размером, расположением и видимостью фрейма карты в компоновке. Во-вторых, существует несколько методов навигации, таких как panToExtent, zoomToAllLayers и zoomToBookmark, которые позволяют изменять область интереса, отображаемую во фрейме карты. В-третьих, свойство map позволяет вам изменять или получать доступ к связанной map. Отсюда вы можете напрямую управлять слоями, таблицами и базовыми картами на карте, а также получать доступ к информации на карте camera, что позволяет вам еще больше изменять область интереса. Вы можете переключать карты одного и того же измерения или разных измерений. Наконец, существует метод export, позволяющий экспортировать фрейм карты в различные форматы.
Подсказка:
Экспорт компоновки MapFrame работает стабильнее, чем попытки экспортировать MapView вне приложения. Ограничением экспорта MapView является то, что представления карты работают только со скриптами Python, выполняемыми внутри приложения. Это связано с тем, что размер окна и область интереса известны только тогда, когда открыто и приложение, и его панели просмотра. При экспорте компоновки MapFrame вся информация о размерах сохраняется в этом элементе, поэтому скрипты, запускаемые как в самом приложении, так и автономные скрипты вне приложения дадут одинаковый результат экспорта.
Синтаксис
addGrid()
Свойства
| Имя | Объяснение | Тип данных |
|---|---|---|
|
anchor (Только для чтения) |
Возвращает одно из следующих строковых значений, которые описывают текущую позицию якоря. Чтобы изменить значение, используйте метод
|
String |
|
camera (Чтение / Запись) |
Свойство Camera позиции расположения и наблюдателя данных, отображаемых в виде карты. |
Camera |
|
elementHeight (Чтение / Запись) |
Высота фрейма карты на компоновке страницы. Единицы измерения задаются или считываются в единицах страницы. |
Double |
|
elementPositionX (Чтение / Запись) |
Х-положение позиции точки якоря фрейма карты. Единицы измерения задаются или считываются в единицах страницы. |
Double |
|
elementPositionY (Чтение / Запись) |
Y-положение позиции точки якоря фрейма карты. Единицы измерения задаются или считываются в единицах страницы. |
Double |
|
elementRotation (Чтение / Запись) |
Угол поворота фрейма карты в градусах Положительные значения поворачивают по часовой стрелке, а отрицательные – против часовой стрелки. Это угол поворота фрейма карты на компоновке, а не угол поворота данных. Воспользуйтесь свойством |
Double |
|
elementWidth (Чтение / Запись) |
Ширина фрейма карты на компоновке страницы. Единицы измерения задаются или считываются в единицах страницы. |
Double |
|
locked (Чтение / Запись) |
Если установлено значение |
Boolean |
|
map (Чтение / Запись) |
Карта, отображенная во фрейме карты. |
Map |
|
name (Чтение / Запись) |
Имя элемента. Важно, чтобы у всех элементов были уникальные имена, благодаря чему на них можно было бы ссылаться с помощью параметра |
String |
|
time (Только для чтения) |
Возвращает объект MapTime, если во фрейме карты есть слои со включенным временем. Значение |
MapTime |
|
type (Только для чтения) |
Возвращает значение |
String |
|
visible (Чтение / Запись) |
Возвращает |
Boolean |
Методы
addGrid(style_item)
Метод addGrid добавляет сетку к MapFrame с помощью элемента стиля.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
style_item |
The reference to a grid |
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 |
String |
createBookmark({name}, {description})
Метод createBookmark создает закладку для карты, связанную с фреймом карты и использующую текущие настройки камеры.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
name (Дополнительный) |
An string that represents the name of the new bookmark. If a name is not provided, the default |
String |
|
description (Дополнительный) |
A string that represents the bookmark's description. If not specified, the value is an empty string. |
String |
Возвращаемое значение
| Тип данных | Объяснение |
|---|---|
|
Bookmark |
Объект bookmark. |
export(export_format, {display_options})
Метод export экспортирует MapFrame, используя указанный export_format.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
export_format |
The supported export format objects are: |
Object |
|
display_options (Дополнительный) |
The |
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). Файлы AIX можно использовать с дополнительным модулем ArcGIS Maps for Adobe Creative Cloud или Adobe Illustrator.
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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) |
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) |
String |
|
jpeg_compression_quality (Дополнительный) |
A number that controls compression quality value when (Значение по умолчанию — 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) |
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 Bitmap (BMP).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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.
(Значение по умолчанию — 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
(Значение по умолчанию — NONE) |
String |
|
embed_color_profile (Дополнительный) |
If set to (Значение по умолчанию — True) |
Boolean |
exportToEMF(out_emf, {resolution}, {image_quality}, {output_as_image}, {convert_markers})
Экспортирует MapFrame в файл формата Enhanced Metafile (EMF).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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) |
String |
|
output_as_image (Дополнительный) |
If set to (Значение по умолчанию — 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 в файл формата Encapsulated PostScript (EPS).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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) |
String |
|
image_quality (Дополнительный) |
A string that specifies output image quality, the draw resolution of map layers that draw as rasters.
(Значение по умолчанию — 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 (Значение по умолчанию — 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 в файл формата Graphic Interchange Format (GIF).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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) |
String |
exportToJPEG(out_jpg, {resolution}, {world_file}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile})
Экспортирует MapFrame в формат Joint Photographic Experts Group (JPEG).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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 (Значение по умолчанию — False) |
Boolean |
|
jpeg_color_mode (Дополнительный) |
This value specifies the number of bits used to describe 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) |
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 в файл Portable Document Format (PDF).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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) |
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) |
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) |
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 (Значение по умолчанию — 80) |
Integer |
|
output_as_image (Дополнительный) |
If set to (Значение по умолчанию — False) |
Boolean |
|
embed_color_profile (Дополнительный) |
If set to (Значение по умолчанию — 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 в формат Portable Network Graphics (PNG).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
out_png |
Строка, представляющая путь и имя выходного файла для экспорта. |
String |
|
resolution (Дополнительный) |
Число, определяющее разрешение файла для экспорта в точках на дюйм (dpi). (Значение по умолчанию — 96) |
Integer |
|
world_file (Дополнительный) |
Если в этом поле установлено значение (Значение по умолчанию — False) |
Boolean |
|
color_mode (Дополнительный) |
Это значение определяет количество битов, используемых для описания цвета.
(Значение по умолчанию — 32-BIT_WITH_ALPHA) |
String |
|
embed_color_profile (Дополнительный) |
Если оно задано как (Значение по умолчанию — True) |
Boolean |
exportToSVG(out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {convert_markers})
Экспортирует MapFrame в файл формата Scalable Vector Graphics (SVG).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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) |
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 (Значение по умолчанию — 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 Graphics Adapter (TGA).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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.
(Значение по умолчанию — 32-BIT_WITH_ALPHA) |
String |
exportToTIFF(out_tif, {resolution}, {world_file}, {color_mode}, {tiff_compression}, {geoTIFF_tags}, {jpeg_compression_quality}, {embed_color_profile})
Экспортирует MapFrame в Tagged Image File Format (TIFF).
Прежние версии:
Этот метод заменен на
exportв версии 3.4 ArcGIS Pro и остается для использования только в устаревших скриптах. Все усовершенствования и будущие разработки будут осуществляться только методом экспорта.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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 (Значение по умолчанию — 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.
(Значение по умолчанию — 24-BIT_TRUE_COLOR) |
String |
|
tiff_compression (Дополнительный) |
This value represents a compression scheme.
(Значение по умолчанию — 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) |
Boolean |
getDefinition(cim_version)
Возвращает определение CIM элемента фрейма карты.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
cim_version |
A string that represents the major version of the CIM that will be used.
|
String |
Возвращаемое значение
| Тип данных | Объяснение |
|---|---|
|
Object |
Возвращает определение CIM для значения |
getLayerExtent(layer, {selection_only}, {symbolized_extent})
Возвращает экстент слоя для всех объектов или только выбранных объектов слоя.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
layer |
Ссылка на объект Layer. |
Layer |
|
selection_only (Дополнительный) |
Если имеет значение (Значение по умолчанию — True) |
Boolean |
|
symbolized_extent (Дополнительный) |
При настройке Истина (True) возвращается символьный экстент; в противном случае возвращается геометрический экстент. Символьный экстент охватывает ту область, которую покрывают символы, так что он не выходит за границы фрейма данных. (Значение по умолчанию — True) |
Boolean |
Возвращаемое значение
| Тип данных | Объяснение |
|---|---|
|
Extent |
Объект геообработки Extent. |
panToExtent(extent)
Перемещает и центрирует фрейм карты MapFrame с использованием объекта Extent без изменения масштаба фрейма карты.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
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.
|
String |
setDefinition(definition_object)
Задает определение CIM элемента фрейма карты.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
definition_object |
A modified CIM definition object originally retrieved using |
Object |
zoomToAllLayers({selection_only}, {symbolized_extent})
Изменяет вид MapFrame, чтобы он соответствовал экстенту всех слоев или выбранных слоев карты.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
selection_only (Дополнительный) |
Если имеет значение (Значение по умолчанию — True) |
Boolean |
|
symbolized_extent (Дополнительный) |
При настройке Истина (True) возвращается символьный экстент; в противном случае возвращается геометрический экстент. Символьный экстент охватывает ту область, которую покрывают символы, так что он не выходит за границы фрейма данных карты. (Значение по умолчанию — True) |
Boolean |
zoomToBookmark(bookmark)
Изменяет вид MapFrame, чтобы он соответствовал информации об элементе, хранящейся вместе с пространственной закладкой.
| Имя | Объяснение | Тип данных |
|---|---|---|
|
bookmark |
Ссылка на объект Bookmark. |
Bookmark |
Пример кода
Следующий скрипт задает экстент фрейма карты различными способами и экспортирует каждый результат в 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)
В следующем скрипте импортируется 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)
В следующем скрипте демонстрируется, как можно создать фрейм карты, используя геометрию 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
В следующем скрипте показано, как можно использовать Python CIM Access для изменения символов границ каждого фрейма карты компоновки.
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)