Resumen
The PNGFormat object represents a collection of Portable Network Graphics (PNG) file properties that can be configured and used with the export method on the Layout, MapFrame, and MapView objects to create an output PNG file.
Debate
PNG is a versatile raster format that can be displayed in web browsers and inserted into other documents. It supports high-bit-depth color and uses a lossless compression. For maps, PNG is often the best raster format, since the lossless compression keeps text and line work legible by preventing the compression artifacts that can occur in JPEG format. PNG files can also define a transparent color; part of the image can be displayed as transparent in a web browser, allowing backgrounds, images, or colors to show through. PNGs can be generated with an accompanying world file for use as georeferenced raster data.
The createExportFormat method can be used to create a PNGFormat object if the format parameter is set to PNG. The returned PNGFormat object contains all the properties associated with a generating a PNG file. These properties can be modified accordingly to produce different output results.
Propiedades
Propiedad | Explicación | Tipo de datos |
clipToElements (Lectura y escritura) | If set to True, include the areas of the page that have map or layout element content only, rather than exporting the entire page. This property only applies when exporting a Layout object. The default value is False. | Boolean |
colorMode (Lectura y escritura) | A string constant that represents the number of bits to describe color in a pixel. The default value is 32-BIT_WITH_ALPHA.
| String |
filePath (Lectura y escritura) | A string that represents the system path and file name, including the extension, for the exported file. | String |
geoReferenceMapFrame (Lectura y escritura) | The MapFrame used to control the coordinate system when the worldFile property is set to True. The default value is None. | MapFrame |
height (Lectura y escritura) | The height, in pixels, of the map area to be exported. This property only applies when exporting a MapView object. The default value is 960. | Double |
resolution (Lectura y escritura) | The effective dpi of the output vector data. The default value is 96. Nota:When exporting a MapView, the dpi is calculated automatically using system dpi scaling and therefore this value will be ignored. | Integer |
showSelectionSymbology (Lectura y escritura) | Show selected features in the map or map frame as selected in the output file. Setting this value to False does not affect selection within the view, only in the output file. The default value is False. | Boolean |
threshold (Lectura y escritura) | Image intensities set above this value will appear white in the output file and all other values will appear black. This property is applied only when the colorMode property is set to 1-BIT_MONOCHROME_THRESHOLD. The default value is 128. | Boolean |
transparentBackground (Lectura y escritura) | If set to True, export a transparent page instead of a white page. This property only applies when exporting a Layout object. The default value is False. Nota:Transparent backgrounds are only supported when colorMode is set to 32-BIT_WITH_ALPHA. This option is not available for maps, but transparency on a map is honored on export. | Boolean |
width (Lectura y escritura) | The width, in pixels, of the map area to be exported. This property only applies when exporting a MapView object. The default value is 960. | Double |
worldFile (Lectura y escritura) | If set to True and a valid georef_mapframe is set, a world file will be generated based on the map frame's coordinate system. The default value is False. | Boolean |
Descripción general del método
Método | Explicación |
setColorMode (color_mode) | A string constant that represents the number of bits to describe color in a pixel. |
Métodos
setColorMode (color_mode)
Parámetro | Explicación | Tipo de datos |
color_mode | Below is a list of valid strings.
| String |
Muestra de código
The following script exports a layout to PNG format using default property values.
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
png = arcpy.mp.CreateExportFormat('PNG', r'C:\Temp\Output.png')
lyt.export(png)