 Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
SQL Anywhere 12.0.0 (Français) » SQL Anywhere Server - Spatial Data Support » Getting started with spatial data » Introduction to spatial data

### How snap-to-grid and tolerance impact spatial calculations

Snap-to-grid is the action of positioning a geometry so it aligns with intersection points on a grid. In the context of spatial data, a grid is a framework of lines that is laid down over a two-dimensional representation of a spatial reference system. SQL Anywhere uses a square grid.

By default, SQL Anywhere automatically sets the grid size so that 12 significant digits can be stored for every point within the X and Y bounds of a spatial reference system. For example, if the range of X values is from -180 to 180, and the range of Y values is from -90 to 90, the database server sets the grid size to 1e-9 (0.000000001). That is, the distance between both horizontal and vertical grid lines is 1e-9. The intersection points of the grid line represents all the points that can be represented in the spatial reference system. When a geometry is created or loaded, each point's X and Y coordinates are snapped to the nearest points on the grid.

Tolerance defines the distance within which two points or parts of geometries are considered equal. This can be thought of as all geometries being represented by points and lines drawn by a marker with a thick tip, where the thickness is equal to the tolerance. Any parts that touch when drawn by this thick marker are considered equal within tolerance. If two points are exactly equal to tolerance apart, they are considered not equal within tolerance.

Note that tolerance can cause extremely small geometries to become invalid. Lines which have length less than tolerance are invalid (because the points are equivalent), and similarly polygons where all points are equal within tolerance are considered invalid.

Snap-to-grid and tolerance are set on the spatial reference system. They are always specified in the linear unit of measure for the spatial reference system. Snap-to-grid and tolerance work together to overcome issues with inexact arithmetic and imprecise data. However, you should be aware of how their behavior can impact the results of spatial operations.

###### Note

For planar spatial reference systems, setting grid size to 0 is never recommended as it can result in incorrect results from spatial operations. For round-Earth spatial reference systems, grid size and tolerance must be set to 0. SQL Anywhere uses fixed grid size and tolerance on an internal projection when performing round-Earth operations.

The following examples illustrate the impact of grid size and tolerance settings on spatial calculations.