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 given, they are prioritized as follows: from top to bottom in the tool dialog 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 type (END | VERTEX | EDGE).
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 one 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).
Caution:
This tool modifies the input data. See Tools that modify or update the input data for more information and strategies to avoid undesired data changes.
Note:
One use case for this tool is to rectify the differences in shared or common boundaries between two datasets by snapping the vertices in one boundary to the vertices, edges, or end points of the other. If the input features do not have enough vertices to match the exact curvature of the other boundary, vertices can be added to the input features using the Densify tool to allow for an added level of detail.
Syntax
arcpy.edit.Snap(in_features, snap_environment)
Parameter | Explanation | Data Type |
in_features | The input features whose vertices 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],...] | Enter the feature classes or feature layers containing the features you wish to snap to. Snapping Environment Components:
Snapping Environment Type Options:
Note:In the Snap Environment parameter, if no unit is entered with the Distance (i.e., 10 instead of 10 Meters), the linear or angular unit from the input feature's coordinate system will be used as default. If the input features have a projected coordinate system, its linear unit will be used. | Value Table |
Derived Output
Name | Explanation | Data Type |
out_feature_class | The updated input features. | Feature Class |
Code sample
The following Python window script demonstrates how to use the Snap tool.
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 climate regions boundary to vegetation layer boundary to ensure 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