STExtractPolygon: Extract Polygons from result of STIntersection in SQL Server Spatial

Oracle customers have asked me for help in the past dealing with compound objects or collections that result from thinning or geoprocessing (intersection etc) of geometry data. Normally this is the need to extract only polygons from the result of an intersection operation. This problem applies to SQL Server Spatial users are the following exampleRead More

STRound: Function to round ordinates of a SQL Server Spatial geometry object

The result of many geoprocessing operations in any spatial type can be geometries with ordinates (X, Y etc) that have far more decimal digits of precision than the initial geometry. I present here a simple function STRound that takes a geometry object and some specifications of the precision of any X, Y, Z or MRead More

STExtract: Extract elements of a geometry object

Of the functions I have written for Oracle, those that allow me to extract (sub)elements of compound (objects consisting of linestrings and circular arcs) and multipart geometries have found use time and time again in such activities as: Filtering Rings of Polygons; Extracting homogeneous objects (eg point, line or polygon) from geometry collections. This articleRead More

STNumRings: Counting number of polygon rings

Here is an “ease of use” function that allows you to count the number of rings of a polygon or multipolygon geometry object in SQL Server Spatial. Some tests. Resulting in: gtype numRings Point 0 MultiPoint 0 LineString 0 MultiLineString 0 Polygon Outer 1 Polygon 3 MultiPolygon 5 CurvePolygon 1 GeometryCollection 1 I hope thisRead More

STFilterRings: Removing rings from Polygon based on area.

A function that have found use in Oracle and PostGIS is one that allows a user to filter out the rings of a polygon or multipolygon based on area. Here is presented a function to do this in SQL Server Spatial. This function requires Denali (2012) as it uses unionAggregate. In addition, the function requiresRead More

STMove: Function to Move a geometry object in SQL Server Spatial

If you have need for a TSQL based function for moving geometry objects in SQL Server Spatial (Denali is required), here is a function you might find useful. Now for some tests Point The result looks like this: Linestring The result looks like this: Move rectangle 10,10 The result looks like this: Curved polygon TheRead More

STCentroid*: Alternate Functions for Compute a Centroid

The top download from my website is for my package of centroid algorithms for Oracle sdo_geometry. There is nothing wrong with the STCentroid function implemented in SQL Server Spatial (for one thing it handles geography objects natively), but it seems that having a choice of centroid algorithms is a big thing for users of spatialRead More

STRotate: Function to rotate a geometry object in SQL Server Spatial

If you have need for a TSQL based function for rotating geometry objects in SQL Server Spatial (Denali is required), here is a function you might find useful. Now for some tests Rotate rectangle about itself and the origin The result looks like this (the background light blue rectangle is the original): Point The resultRead More

STVertices: Wrapper over STDumpPoints

Oracle’s point dumping function, mdsys.sdo_util.getVertices is most useful. When swapping between platforms sometimes I look first for such a function in SQL Server Spatial forgetting that I named it DumpPoints Here is a “wrapper” function for STDumpPoints. Testing it…. Result x y 148 -44 148 -43 147 -43 147 -44 148 -44 147.4 -43.6 147.2Read More

STMorton: Creating a Morton Number Space Key Value for Grid Cells

Introduction NOTE: This article is a copy of the original first written in 2010 from my old website. Space curves are imaginary lines that systematically cover all tiles in an indexed space. The most well known in GIS is the Morton key. The utility of such a number can be seen though its implementing aRead More