ST Class
Overview
The ST static class provides a common set of spatial operations that can be used consistently in both SQLite and C#. Rather than maintaining separate implementations for application code and database queries, developers can work with a familiar set of spatial concepts across both environments.
This unified model makes it easier to move spatial logic between application code and the database. Operations such as creating geometries, calculating distances, testing spatial relationships, and performing geometric transformations can be expressed using the same conceptual API, whether they are executed in-memory through C# or within SQLite queries.
C# Namespace
Constructors
| Name | Description |
|---|---|
| ST_Point | Creates a point geometry. |
| ST_GeomFromText | Creates a geometry using WKT definition. |
Methods
| Name | Description |
|---|---|
| ST_Area | Calculates the area of a polygon geometry. |
| ST_AsText | Returns the WKT representation of the geometry. |
| ST_Boundary | Computes the boundary of a geometry. |
| ST_Buffer | Computes a buffer region around a geometry. |
| ST_Centroid | Calculates the geometric center (centroid) of a geometry. |
| ST_Contains | Determines whether one geometry contains another. |
| ST_ConvexHull | Computes the convex hull of a geometry. |
| ST_CoveredBy | Determines whether one geometry is spatially covered by another. |
| ST_Covers | Determines whether one geometry spatially covers another. |
| ST_Crosses | Determines whether two geometries cross each other. |
| ST_Difference | Computes the geometric difference between two geometries. |
| ST_Disjoint | Determines whether two geometries are spatially disjoint. |
| ST_Distance | Calculates the shortest distance between two geometries. |
| ST_Equals | Determines whether two geometries are topologically equal. |
| ST_EqualsExact | Determines whether two geometries are exactly equal in both shape and coordinate order. |
| ST_EqualsNormalized | Determines whether two geometries are equal after applying a normalization process. |
| ST_EqualsTopologically | Determines whether two geometries are topologically equal. |
| ST_Envelope | Computes the minimum bounding rectangle (MBR), also known as the envelope, of a geometry. |
| ST_GeometryType | Returns the type of geometry. |
| ST_Height | Calculates the height of the minimum bounding rectangle (MBR), also known as the envelope, for a given geometry. |
| ST_InteriorPoint | Returns a point guaranteed to lie in the interior of a given geometry. |
| ST_Intersection | Computes the geometric intersection of two geometries. |
| ST_Intersects | Determines whether two geometries intersect. |
| ST_IsEmpty | Tests whether the set of points covered in this Geometry is empty. |
| ST_IsGeometry | Tests for a valid geometry. |
| ST_IsRectangle | Test whether the a given geometry represents a valid axis-aligned rectangle. |
| ST_IsSimple | Tests whether a given geometry is simple. |
| ST_IsValid | Tests whether a given is topologically valid. |
| ST_Length | Calculates the total length of a geometry. |
| ST_Reverse | Reverses the order of vertices in a linear geometry. |
| ST_SetSRID | Assigns a SRID to a geometry. |
| ST_SRID | Retrieves the SRID from a geometry. |
| ST_SymmetricDifference | Computes the symmetric difference between two geometries. |
| ST_Touches | Determines whether two geometries touch at their boundaries. |
| ST_Union | Computes the spatial union of two geometries. |
| ST_Width | Calculates the width of the minimum bounding rectangle (MBR), also known as the envelope, for a given geometry. |
| ST_Within | Determines whether the first geometry is completely contained within the second geometry. |
| ST_X | Extracts the X-coordinate of the centroid of a geometry. |
| ST_XMax | Returns the Y maximum of a bounding box or a geometry. |
| ST_XMin | Returns the X minimum of a bounding box or a geometry. |
| ST_Y | Extracts the Y-coordinate of the centroid of a geometry. |
| ST_YMax | Returns the Y maximum of a bounding box or a geometry. |
| ST_YMin | Returns the Y minimum of a bounding box or a geometry. |
ST_Area
Calculates the area of a polygon geometry provided in EWKB format. If the input is null or invalid, the method returns null. The area is computed assuming planar geometry and is expressed in the same units as the coordinate system of the input.
ST_AsText
Returns the OGC Well-Known Text (WKT) representation of the geometry.
ST_Boundary
Computes the boundary of a geometry from its EWKB representation. For a polygon, the boundary consists of its exterior and interior rings. For a linestring, the boundary includes its endpoints. Returns a EWKB representing the boundary geometry.
ST_Buffer
Computes a buffer region around a geometry defined by its EWKB representation. The buffer is a polygon that encloses all points within the specified distance from the original geometry.
ST_Centroid
Calculates the geometric center (centroid) of a geometry provided in EWKB format. The centroid is the arithmetic mean position of all the points in the shape and may not necessarily lie within the geometry itself (e.g., for concave polygons).
ST_Contains
Determines whether one geometry contains another, based on their EWKB representations. The method returns 1 (true) if the first geometry completely contains the second, and 0 (false) otherwise.
ST_ConvexHull
Computes the convex hull of a geometry provided in EWKB format. The convex hull is the smallest convex polygon that fully encloses all points of the input geometry.
ST_CoveredBy
Determines whether one geometry is spatially covered by another, based on their EWKB representations. A geometry is considered "covered by" another if every point of the first geometry lies within or on the boundary of the second geometry. The method returns 1 (true) if the first geometry is covered by the second, and 0 (false) otherwise.
ST_Covers
Determines whether one geometry spatially covers another, based on their EWKB representations. A geometry covers another if every point of the second geometry lies within or on the boundary of the first. The method returns 1 (true) if the first geometry covers the second, and 0 (false) otherwise.
ST_Crosses
Determines whether two geometries cross each other, based on their EWKB representations. Two geometries cross if they share some but not all interior points, and the result of their intersection has a lower dimension than the maximum of the input geometries. The method returns 1 (true) if the first geometry crosses the second, and 0 (false) otherwise.
ST_Difference
Computes the geometric difference between two geometries provided in EWKB format. The result is a new geometry representing the portion of the first geometry that does not intersect with the second geometry.
ST_Disjoint
Determines whether two geometries are spatially disjoint, based on their EWKB representations. Two geometries are disjoint if they do not share any points - meaning their intersection is empty. The method returns 1 (true) if the two geometries are disjoint, and 0 (false) otherwise.
ST_Distance
Calculates the shortest distance between two geometries provided in EWKB format. The result is a non-negative value representing the minimum distance between any two points from the input geometries. If either input is null or invalid, the method returns null.
ST_Equals
Determines whether two geometries are topologically equal, based on their EWKB representations. Two geometries are considered topologically equal if they represent the same spatial structure, regardless of differences in coordinate order or representation. The method returns 1 (true) if the first geometry is topologically equal to the second, and 0 (false) otherwise.
ST_EqualsExact
Determines whether two geometries are exactly equal in both shape and coordinate order, based on their EWKB representations. This method performs a strict comparison, requiring that both geometries have identical types, vertex sequences, and structure. The method returns 1 (true) if the first geometry is exactly equal to the second, and 0 (false) otherwise.
ST_EqualsNormalized
Determines whether two geometries are equal after applying a normalization process, based on their EWKB representations. Normalized equality means the geometries are structurally and spatially identical after standardizing their internal representation (e.g., ordering of coordinates, ring orientation). The method returns 1 (true) if the first geometry is equal to the second, and 0 (false) otherwise.
ST_EqualsTopologically
Determines whether two geometries are topologically equal, based on their EWKB representations. Two geometries are considered topologically equal if they represent the same spatial structure, regardless of differences in coordinate order or representation. The method returns 1 (true) if the first geometry is topologically equal to the second, and 0 (false) otherwise.
ST_Envelope
Computes the minimum bounding rectangle (MBR), also known as the envelope, of a geometry provided in EWKB format. The envelope is the smallest axis-aligned rectangle that fully contains the input geometry.
ST_GeometryType
Returns the type of geometry represented by a EWKB representation. This method identifies the geometry class and returns it as a string.
ST_GeomFromText
Constructs a geometry object from the OGC Well-Known text representation.
ST_Height
Calculates the height of the minimum bounding rectangle (MBR), also known as the envelope, for a given geometry in EWKB format. The height is the difference between the maximum and minimum Y-coordinates of the geometry's envelope.
ST_InteriorPoint
Returns a point guaranteed to lie in the interior of a given geometry, based on its EWKB representation. This method is especially useful for labeling or anchoring geometries such as polygons or multipolygons.
ST_Intersection
Computes the geometric intersection of two geometries provided in EWKB format. The result is a new geometry representing the shared spatial area between the two inputs - where they overlap or touch.
ST_Intersects
Determines whether two geometries intersect, based on their EWKB representations. Two geometries intersect if they share at least one point in space, including touching at boundaries or overlapping interiors. The method returns 1 (true) if the first geometry intersects the second, and 0 (false) otherwise.
ST_IsEmpty
Tests whether the set of points covered in this Geometry is empty. Note this test is for topological emptiness, not structural emptiness. A collection containing only empty elements is reported as empty. The method returns 1 (true) if the geometry is empty, and 0 (false) otherwise.
ST_IsGeometry
Tests whether the data supplied is a valid EWKB representation of a geometry. The method returns 1 (true) if the text is a valid WKT representation of geometry, and 0 (false) otherwise.
ST_IsRectangle
Determines whether a given geometry, provided in EWKB format, represents a valid axis-aligned rectangle. This method checks for rectangular shape, closed polygon structure, and right-angle alignment. The method returns 1 (true) if the geometry is a rectangle, and 0 (false) otherwise.
ST_IsSimple
Tests whether a given geometry, provided in EWKB format, is simple. Geometry is simple if it has no points of self-tangency, self-intersection, or other anomalous points. The method returns 1 (true) if the geometry is simple, and 0 (false) otherwise.
ST_IsValid
Tests whether a given geometry, provided in EWKB format, is topologically valid according to the OGC SFS specification. The method returns 1 (true) if the geometry is valid, and 0 (false) otherwise.
ST_Length
Calculates the total length of a geometry provided in EWKB format. This method is typically used for linear geometries such as LINESTRING or MULTILINESTRING, and returns the sum of all segment lengths. If the input is null or invalid, the method returns null.
ST_Point
Returns a Point with the given X and Y coordinate values.
ST_Reverse
Reverses the order of vertices in a linear geometry provided in EWKB format. This method is typically used with LINESTRING or MULTILINESTRING geometries to invert the direction of traversal.
ST_SetSRID
Assigns a Spatial Reference System Identifier (SRID) to a geometry represented in EWKB format. The SRID defines the coordinate system and projection used for interpreting the geometry's coordinates. This method does not alter the geometry itself, only its spatial reference metadata.
ST_SRID
Retrieves the Spatial Reference System Identifier (SRID) from a geometry represented in EWKB format. The SRID defines the coordinate system and projection used to interpret the geometry's coordinates.
ST_SymmetricDifference
Computes the symmetric difference between two geometries provided in EWKB format. The symmetric difference is the set of points that belong to either geometry but not to both - essentially the non-overlapping portions of the two inputs.
ST_Touches
Determines whether two geometries touch at their boundaries but do not overlap in their interiors, based on their EWKB representations. This method returns 1 (true) if the geometries share at least one boundary point and their interiors do not intersect, and 0 (false) otherwise.
ST_Union
Computes the spatial union of two geometries provided in Well-Known Text (WKT) format. The union operation returns a geometry that represents all points from both input geometries, merging overlapping areas and combining disjoint parts into a single result.
ST_Width
Calculates the width of the minimum bounding rectangle (MBR), also known as the envelope, for a given geometry in EWKB format. The width is the difference between the maximum and minimum X-coordinates of the geometry's envelope.
ST_Within
Determines whether the first geometry is completely contained within the second geometry, based on their EWKB representations. This method returns 1 (true) if every point of the first geometry lies inside the second geometry, including its boundary, and 0 (false) otherwise.
ST_X
Extracts the X-coordinate of the centroid (geometric center) of a geometry provided in EWKB format. The centroid represents the average position of all points in the geometry and is useful for labeling, spatial indexing, and geometric analysis.
ST_XMax
Returns the X maximum of a bounding box or a geometry.
ST_XMin
Returns the X minimum of a bounding box or a geometry.
ST_Y
Extracts the Y-coordinate of the centroid (geometric center) of a geometry provided in EWKB format. The centroid represents the average position of all points in the geometry and is useful for labeling, spatial indexing, and geometric analysis.
ST_YMax
Returns the Y maximum of a bounding box or a geometry.
real ST_YMax(blob ewkb)
ST_YMin
Returns the Y minimum of a bounding box or a geometry.