ExportToSVG (arcpy.mapping)

Récapitulatif

Exports the page layout or data frame of a map document (.mxd) to the Scalable Vector Graphics (SVG) format.

Discussion

SVG is an XML-based file format that has been specifically designed for viewing on the Web. SVG can contain both vector and raster information. This is a good choice for displaying maps on a web page because it is rescalable and more easily edited than raster files. SVG has been gaining in popularity since the World Wide Web Consortium (W3C) selected it as their standard vector Web format. Some Web browsers may require a plug-in to view SVG files; older browsers may not be able to view SVG files at all. SVG supports font embedding, so users who do not have the Esri fonts installed can still view ArcMap SVG exports with proper symbology. ArcMap can also produce compressed SVG files. The file extension changes to *.SVGZ when this option is enabled.

To export a single data frame instead of the entire page layout, pass a DataFrame object to the function's data_frame parameter. Because data frame exports do not have an associated page to provide height and width information, you must provide this via the df_export_width and df_export_height parameters.

Controlling graphic quality of the generated image differs for page layout exports versus data frame exports. When exporting a page layout, control image detail by changing the resolution parameter. When exporting a data frame, keep the resolution parameter at its default value, and change the df_export_width and df_export_height parameters to alter image detail. The height and width parameters directly control the number of pixels generated in the export file and are only used when exporting a data frame. Images with larger numbers of pixels will have higher image detail. For most page layout exports, the default parameter values should generate good results and nice looking export images on the first try. For data frame exports, you may need to experiment with the df_export_width and df_export_height values a few times before getting the result you want.

Refer to the Exporting your map topic in ArcGIS Help for more detailed discussions on exporting maps.

Syntaxe

ExportToSVG (map_document, out_svg, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {image_quality}, {compress_document}, {picture_symbol}, {convert_markers}, {embed_fonts})
ParamètreExplicationType de données
map_document

A variable that references a MapDocument object.

MapDocument
out_svg

A string that represents the path and file name for the output export file.

String
data_frame

A variable that references a DataFrame object. Use the string/constant "PAGE_LAYOUT" to export the map document's page layout instead of an individual data frame.

(La valeur par défaut est PAGE_LAYOUT)

Object
df_export_width

A number that defines the width of the export image in pixels for a data frame export. df_export_width is only used when exporting a data frame. Exporting a page layout uses the map document page width instead of df_export_width.

(La valeur par défaut est 640)

Integer
df_export_height

A number that defines the height of the export image in pixels for a data frame export. df_export_height is only used when exporting a data frame. Exporting a page layout uses the map document page height instead of df_export_height.

(La valeur par défaut est 480)

Integer
resolution

A number that defines the resolution of the export file in dots per inch (DPI).

(La valeur par défaut est 300)

Integer
image_quality

A string that defines 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.

(La valeur par défaut est BEST)

String
compress_document

If set to True, a compressed export will be created. For SVG, the entire document is compressed and it changes the file extension to *.svgz.

(La valeur par défaut est False)

Boolean
picture_symbol

A string that defines whether picture markers and picture fills will be converted to vector or rasterized on output.

  • RASTERIZE_BITMAP Rasterize layers with bitmap markers/fills.
  • RASTERIZE_PICTURERasterize layers with any picture marker/fill.
  • VECTORIZE_BITMAPVectorize layers with bitmap markers/fills.

(La valeur par défaut est RASTERIZE_BITMAP)

String
convert_markers

A Boolean that controls the coversion 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.

(La valeur par défaut est False)

Boolean
embed_fonts

A Boolean that controls the embedding of fonts in export files. 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.

(La valeur par défaut est False)

Boolean

Exemple de code

ExportToSVG example 1

This script opens a map document and exports the page layout to an SVG file using default values for all options.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
arcpy.mapping.ExportToSVG(mxd, r"C:\Project\Output\Project.svg")
del mxd
ExportToSVG example 2

This script will export a single data frame instead of the entire page layout, similar to exporting from data view in the ArcMap application. The default values for df_export_width and df_export_height are 640 and 480. By passing larger values for these parameters, we are able to produce an output image with higher detail.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
arcpy.mapping.ExportToSVG(mxd, r"C:\Project\Output\ProjectDataFrame.svg", df,
                          df_export_width=1600,
                          df_export_height=1200)
del mxd
9/12/2013