Snap (Editing)
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 usually be snapped to the feature with the higher Object ID. For example, if points OBJECTID 1 and OBJECTID 2 are within the snapping distance, the point with OBJECTID 1 will be snapped to the location of the point with OBJECTID 2 (and not vice versa). Use the Sort tool to rearrange features so this snapping behavior can be controlled.
-
When the tool is used in ArcMap, the Snap Environment of the application is defaulted into the Snap Environment parameter, where it can be modified if desired.
This tool modifies the input data. See Tools with no outputs for more information and strategies to avoid undesired data changes.
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
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],...] |
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, the linear unit will be used. | Value Table |
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 # Author: ESRI # import system modules import arcpy from arcpy import env # Set environment settings 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])