Spatial operations use geometry functions to take spatial data as input, analyze the data, then produce output data that is the derivative of the analysis performed on the input data.

The following operations can be done to create new data from input data.

## Buffering geometry

The ST_Buffer function generates a geometry by encircling a geometry at a specified distance. A single polygon results when a primary geometry is buffered or when the buffer polygons of a collection are close enough to overlap. When enough separation exists between the elements of a buffered collection, individual buffer ST_Polygons result in an ST_MultiPolygon.

The ST_Buffer function accepts both positive and negative distances, but only geometries with a dimension of 2 (ST_Polygon and ST_MultiPolygon) can apply a buffer with a negative distance. The absolute value of the buffer distance is used when the dimension of the source geometry is less than 2; in other words, all geometries that are neither ST_Polygon nor ST_MultiPolygon. Generally speaking, positive buffer distances generate polygon rings that are away from the center of the source geometry and—for the exterior ring of an ST_Polygon or ST_MultiPolygon—toward the center when the distance is negative. For interior rings of an ST_Polygon or ST_MultiPolygon, the buffer ring is toward the center when the buffer distance is positive and away from the center when it is negative. The buffering process merges buffer polygons that overlap. Negative distances greater than one-half the maximum interior width of a polygon result in an empty geometry.

See ST_Buffer for syntax and an example.

## ConvexHull

The ST_ConvexHull function returns the convex hull polygon of any geometry that has at least three vertices forming a convex. If vertices of the geometry do not form a convex, ST_ConvexHull returns a null. For example, using ST_ConvexHull on a line composed of two vertices will return a null. Similarly, using the ST_ConvexHull operation on a point feature will return a null. Creating a convex hull is often the first step when tessellating a set of points to create a triangulated irregular network (TIN).

See ST_ConvexHull for syntax and an example.

## Difference of geometries

The ST_Difference function returns the portion of the primary geometry that is not intersected by the secondary geometry—the logical AND NOT of space. The ST_Difference function only operates on geometries of similar dimension and returns a collection that has the same dimension as the source geometries. In the event that the source geometries are equal, an empty geometry is returned.

See ST_Difference for syntax and an example.

## Intersection of geometries

The ST_Intersection function returns the intersection set of two geometries. The intersection set is always returned as a collection that is the minimum dimension of the source geometries. For example, for an ST_LineString that intersects an ST_Polygon, the ST_Intersection function returns that portion of the ST_LineString common to the interior and boundary of the ST_Polygon as an ST_MultiLineString. The ST_MultiLineString contains more than one ST_LineString if the source ST_LineString intersected the ST_Polygon with two or more discontinuous segments. If the geometries do not intersect or if the intersection results in a dimension less than both source geometries, an empty geometry is returned. The following figure illustrates some examples of the ST_Intersection function.

See ST_Intersection for syntax and an example.## Symmetric difference of geometries

The ST_SymmetricDiff function returns the symmetric difference of two geometries—the logical XOR of space. The source geometries must have the same dimension. If the geometries are equal, the ST_SymmetricDiff function returns an empty geometry; otherwise, the function returns the result as a collection.

See ST_SymmetricDiff for syntax and example.

## Union of geometries

The ST_Union function returns the union set of two geometries—the Boolean logical OR of space. The source geometries must have the same dimension. ST_Union always returns the result as a collection.

See ST_Union for syntax and example.

## Minimum distance

The previous functions returned new geometries. The ST_Distance function takes two features as input and returns the minimum distance between the two.

The minimum distance separating features represents the shortest distance between two locations (as the crow flies). For instance, this is not the distance you would have to travel if you drive from one location to the other, but the distance you would calculate if you drew a straight line between two locations on a map. The ST_Distance function reports the minimum distance separating two disjoint geometries. If the geometries are not disjoint (in other words, they are coincident), the function reports a zero minimum distance.

## Aggregates

Aggregate operations return a single geometry as a result of analysis performed on a collection of geometries. The ST_Aggr_ConvexHull function returns the multipolygon composed of the convex hull polygons of each of the input geometries. Any input geometry with fewer than three vertices will not have a convex hull. If all of the input geometries have fewer than three vertices, ST_Aggr_ConvexHull returns a null.

The ST_Aggr_Intersection function returns a single geometry that is an aggregation of the intersections of all input geometries. A query may discover numerous features that intersect. If you used the ST_Intersection operator, multiple features that represent the intersection of each set of geometries would be returned. For example, if you did an intersection of a line and a point feature class, one ST_Point geometry would be returned for every intersection.

Using ST_Aggr_Intersection instead, you would get one geometry collection. For example, if you want one geometry representing the intersection of the line and point feature classes mentioned previously, ST_Aggr_Intersection returns one ST_MultiPoint geometry composed of all the points of intersection. If only one point and one line intersect, though, you will get an ST_Point geometry.

ST_Aggr_Intersection allows you to find the intersection of multiple geometries whereas ST_Intersection only finds the intersection between two geometries. For example, if you wanted to find property that was covered by different specific services, such as a specific school district, phone service, and high-speed Internet provider, and was represented by a specific council person, you need to find the intersection of all those areas. Finding the intersection of only two of those areas would not return all of the information you need, so you would use the sde.ST_Aggr_Intersection function so that all the areas could be evaluated in the same query.

The ST_Aggr_Union function returns one geometry that is the union of all the provided geometries. The input geometries must be of the same type; for example, you can union ST_LineStrings with ST_LineStrings or you can union ST_Polygons with ST_Polygons, but you cannot union an ST_LineString feature class with an ST_Polygon feature class. The geometry that results from the aggregate union is usually a collection. For example, if you want the aggregate union of all the vacant parcels smaller than half an acre, the returned geometry will be a multipolygon, unless all the parcels that meet the criteria are contiguous, then one polygon would be returned.