Skip to main content
Snap the vertices and segments of the geometry to vertices of the reference. Vertices and segments of the input geometry are snapped to vertices of the reference geometry, returning a new geometry; the input geometries are not modified. The result geometry is the input geometry with the vertices and segments snapped. If no snapping occurs then the input geometry is returned unchanged. The tolerance is used to control where snapping is performed. Where possible, this operation tries to avoid creating invalid geometries; however, it does not guarantee that output geometries will be valid. It is the responsibility of the caller to check for and handle invalid geometries. Because too much snapping can result in invalid geometries being created, heuristics are used to determine the number and location of snapped vertices that are likely safe to snap. These heuristics may omit some potential snaps that are otherwise within the tolerance. Note: Sedona’s result may differ slightly from geopandas’s snap() result because of small differences between the underlying engines being used. The operation works in a 1-to-1 row-wise manner:

Signature

Parameters

GeoSeries or geometric object
required
The Geoseries (elementwise) or geometric object to snap to.
float or array like
required
Maximum distance between vertices that shall be snapped
bool | None (default None)
default:"None"
If True, automatically aligns GeoSeries based on their indices. None defaults to True. If False, the order of elements is preserved.

Returns

GeoSeries

Examples

We can snap each geometry to a single shapely geometry:
We can also snap two GeoSeries to each other, row by row. The GeoSeries above have different indices. We can either align both GeoSeries based on index values and snap elements with the same index using align=True or ignore index and snap elements based on their matching order using align=False: