HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Spatial query to get enclosing radius/polygon of result set

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
resultsetqueryradiusgetpolygonspatialenclosing

Problem

Is it possible in SQL to run a query of spatial data, and then just return a single polygon, or a radius, that encloses, aggregates, all of the spatial data that was in that query into one feature?

Solution

Yes, using SQL Server's

  • "Static Aggregate Geometry Methods"



  • "Static Aggregate Geography Methods"



You essentially have three options

  • ConvexHull: returns a polygon that essentially wraps the input with a rubber band,



  • EnvelopeAggregate: returns a bounding box (polygon) that encapsulates the input (box = lines in a cartesian project, arc segments in a 3d/spheroid/geographic projection)



  • UnionAggregate: takes all of the inputs and composes them into a single complex-polygon



Note: you mention radius, a radius is a buffer over an input in GIS.

If you need more features, you should check out the free PostgreSQL and PostGIS which supports even more GIS functionality.

Context

StackExchange Database Administrators Q#202634, answer score: 4

Revisions (0)

No revisions yet.