Summary
Moves points or vertices to coincide exactly with the vertices, edges, or end points of other features. Snapping rules can be specified to control whether the input vertices are snapped to the nearest vertex, edge, or endpoint within a specified distance.
Illustration
Usage
The Snap Environment parameter allows for the vertices of the input features to be snapped to the vertices, edges, and end points of multiple layers or feature classes. When multiple snapping rules are provided, they are prioritized from top to bottom on the tool dialog box or from left to right in scripting.
The input features' vertices will be snapped to the nearest vertex, edge, or end point within the specified distance.
In the Snap Environment parameter, multiple snap rules can be designated using the same layer or feature class with a different snapping type.
If a layer or feature class with a selection is used as the input, only vertices of the selected features will be snapped.
When snapping features in a feature class to features in the same feature class, the feature with the lower Object or Feature ID will typically be snapped to the feature with the higher Object ID (OBJECTID field or FID field for shapefiles). For example, if points with OBJECTID field values of 1 and 2 are within the snapping distance, the point with an OBJECTID field value of 1 will be snapped to the location of the point with an OBJECTID field value of 2 (and not vice versa).
Syntax
arcpy.edit.Snap(in_features, snap_environment)
Parameter | Explanation | Data Type |
in_features | The input features with the vertices that will be snapped to the vertices, edges, or end points of other features. The input features can be points, multipoints, lines, or polygons. | Feature Layer |
snap_environment [[Features, Type, Distance],...] | The feature classes or feature layers containing the features to snap to. The snapping environment components are as follows:
Available snapping types are as follows:
| Value Table |
Derived Output
Name | Explanation | Data Type |
out_feature_class | The updated input features. | Feature Class |
Code sample
Snap example 1 (Python window)
The following Python window script demonstrates how to use the Snap function.
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.Snap_edit("climate.shp",
[["Habitat_Analysis.gdb/vegtype", "VERTEX", "30 Feet"],
["Habitat_Analysis.gdb/vegtype", "EDGE", "20 Feet"]])
Snap example 2 (stand-alone script)
Snap the climate regions boundary to the vegetation layer boundary to ensure the common boundary is coincident.
# Name: Snap.py
# Description: Snap climate regions boundary to vegetation layer boundary
# to ensure common boundary is coincident
# import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:/data"
# Make backup copy of climate regions feature class, since modification with
# the Editing tools below is permanent
climate = "climate.shp"
climateBackup = "C:/output/Output.gdb/climateBackup"
arcpy.CopyFeatures_management(climate, climateBackup)
# Densify climate regions feature class to make sure there are enough vertices
# to match detail of vegetation layer when layers are snapped
arcpy.Densify_edit(climate, "DISTANCE", "10 Feet")
# Snap climate regions feature class to vegetation layer vertices and edge
veg = "Habitat_Analysis.gdb/vegtype"
# First, snap climate region vertices to the nearest vegetation layer vertex
# within 30 Feet
snapEnv1 = [veg, "VERTEX", "30 Feet"]
# Second, snap climate region vertices to the nearest vegetation layer edge
# within 20 Feet
snapEnv2 = [veg, "EDGE", "20 Feet"]
arcpy.Snap_edit(climate, [snapEnv1, snapEnv2])
Environments
Licensing information
- Basic: No
- Standard: Yes
- Advanced: Yes