Spatial operations
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.
Derived data you can obtain from a spatial operation includes the following:
- A polygon that is a buffer around an input feature
A single feature that is a result of analysis performed on a collection of geometries
- A single feature that is the result of a comparison to determine the part of a feature that does not inhabit the same physical space as another feature
- A single feature that is the result of a comparison to find the parts of a feature that intersect the physical space of another feature
- A multipart feature that is made up of the parts of both input features that do not inhabit the same physical space as one another
- A feature that is the union of two geometries
The analysis performed on the input data returns the coordinates or text representation of the resultant geometries. You can use that information as part of a larger query to perform further analysis, or you can use the results as input to another table.
For example, you could include a buffer operation in the WHERE clause of an intersect query to determine if the specified geometry intersects an area of specified size around another geometry.
The following examples use ST_Geometry functions. For the specific geometry functions and syntax used for another database and spatial data type, read the documentation specific to that database and data type.
In this example, notifications have to be sent to all property owners within 1,000 feet of a street closure. The WHERE clause generates a 1,000-foot buffer around the street that will be closed. That buffer is then compared to the properties in the area to see which ones are intersected by the buffer.
SELECT p.owner,p.address,s.stname FROM parcels p, streets s WHERE s.stname = 'Main' AND sde.st_intersects (p.shape, sde.st_buffer (s.shape, 1000)) = 't';
In this example, one specific street (Main) is chosen in the WHERE clause, then a buffer is created around the street and compared to the features in the parcels table to determine if they intersect.* For all parcels that are intersected by the buffer on Main Street, the parcel owner name and address are returned.
*The order in which the parts of the WHERE clause are executed depends on the database optimizer.
The following is an example of taking the results of a spatial operation (union) performed on tables containing neighborhood and school district areas and inserting the resultant features into another table:
INSERT INTO combo c (shape) VALUES ( (SELECT sde.st_union (n.shape,d.shape) FROM neighborhoods n, school_districts d),5);
For more information on using spatial operators with ST_Geometry, see Spatial operation functions for ST_Geometry. For information on using spatial operators with IBM DB2, IBM Informix, Oracle Spatial, PostGIS, or Microsoft SQL Server spatial types, see the documentation for those database management systems.