Graphics To Features (Conversion)

Summary

Converts a graphics layer into a feature layer with geometries based on the input graphics layer's elements.

Usage

  • Only one type of graphic element can be converted to features at a time.

  • Text elements will be converted to annotation. The full appearance of the element will be preserved.

  • This tool is commonly used to convert a selection (subset) of graphic elements to features.

  • If the Delete graphics after conversion parameter is checked, the tool will delete the graphic elements and new features will be drawn in their place. This allows the conversion process to be completed in one step.

Parameters

LabelExplanationData Type
Input Graphics

The graphics layer containing the source graphic elements that will be converted to features.

Graphics Layer
Graphics Type

Specifies the type of graphic element that will be converted.

  • PointPoint graphic elements will be converted.
  • PolylinePolyline graphic elements will be converted.
  • PolygonPolygon graphic elements will be converted.
  • MultipointMultipoint graphic elements will be converted.
  • AnnotationAnnotation and text graphic elements will be converted.
String
Output Feature Class

The output feature layer that will contain the converted graphic elements.

Feature Class
Delete graphics after conversion
(Optional)

Specifies whether the converted graphic elements from the Input Graphics parameter will be deleted after conversion.

  • Checked—The graphic elements will be deleted. This is the default.
  • Unchecked—The graphic elements will not be deleted; they will be preserved.

Boolean
Reference Scale
(Optional)

The reference scale that will be used to convert text elements to annotation features. This parameter is required when the Graphics Type parameter is set to Annotation.

Double

Derived Output

LabelExplanationData Type
Updated layer

The updated input layer with deleted graphic elements if the Delete graphics after conversion parameter is checked.

Graphics Layer

arcpy.conversion.GraphicsToFeatures(in_layer, graphics_type, out_feature_class, {delete_graphics}, {reference_scale})
NameExplanationData Type
in_layer

The graphics layer containing the source graphic elements that will be converted to features.

Graphics Layer
graphics_type

Specifies the type of graphic element that will be converted.

  • POINTPoint graphic elements will be converted.
  • POLYLINEPolyline graphic elements will be converted.
  • POLYGONPolygon graphic elements will be converted.
  • MULTIPOINTMultipoint graphic elements will be converted.
  • ANNOTATIONAnnotation and text graphic elements will be converted.
String
out_feature_class

The output feature layer that will contain the converted graphic elements.

Feature Class
delete_graphics
(Optional)

Specifies whether the converted graphic elements from the in_layer parameter will be deleted after conversion.

  • DELETE_GRAPHICSThe converted graphic elements will be deleted. This is the default.
  • KEEP_GRAPHICSThe converted graphic elements will not be deleted; they will be preserved.
Boolean
reference_scale
(Optional)

The reference scale that will be used to convert text elements to annotation features. This parameter is required when the graphics_type parameter is set to ANNOTATION.

Double

Derived Output

NameExplanationData Type
updated_layer

The updated input layer with deleted graphic elements if the delete_graphics parameter is set to DELETE_GRAPHICS.

Graphics Layer

Code sample

GraphicsToFeatures example 1 (Python window)

The following Python snippet converts a graphics layer containing polygon graphic elements to a polygon feature layer from the Python window.

import arcpy
arcpy.env.workspace = r"C:/data/input/myProject.aprx"
arcpy.conversion.GraphicsToFeatures("polygonGraphics", "POLYGON", 
																																				"polygonFeatures", "DELETE_GRAPHICS")
GraphicsToFeatures example 2 (stand-alone script)

The following Python script adds a graphics layer of point locations to a map, converts the graphics to a feature class, calculates the x,y coordinates of these points, and adds the fields to the attribute table.


# Name: GraphicsToFeatures.py
# Description: Converts a point graphics layer to a feature class and adds x,y 
# coordinate data to its attributes.
# Requirements: None

import arcpy

# Set environment
arcpy.env.workspace = r"C:\Data"

# Set local variables
in_layer = "graphics_coord.lyrx"
out_path = "Default.gdb"
geometry_type = "POINT"
result = arcpy.management.CreateFeatureclass(out_path, "out_fc", geometry_type)

# Execute the conversion
arcpy.conversion.GraphicsToFeatures(in_layer, 'POINT', result, 'DELETE_GRAPHICS')

# Add x,y coordinates to the new feature class
arcpy.management.AddXY("out_fc")

Related topics