Class SpatialArea
- Namespace
- YndigoBlue.Velocity.Functions
- Assembly
- YndigoBlue.Velocity.dll
Represents the ST_Area spatial function that calculates the area of a polygon or multi-polygon geometry.
public class SpatialArea : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
- Inheritance
-
SpatialArea
- Implements
Remarks
Warning
Spatial functions are not available in the Community Edition of Velocity. They require the Full Edition.
The ST_Area function returns the area of a geometry. For Geometry types (planar), it calculates area in coordinate system units squared. For Geography types (spherical), it calculates area on the earth's surface, optionally in specified units. Returns 0 for non-areal geometries (points, lines). Useful for land area calculations, geographic analysis, and spatial statistics. OGC-compliant.
Geometry Mode (planar, returns square coordinate units):
| Shape | Area |
|---|---|
| PY0 (4°×4° square) | 16.0 |
| PY1 (0.5°×1° rectangle) | 0.5 |
| PY2 (1°×3° rectangle) | 3.0 |
| PY3 (triangle) | 0.25 |
| PY4 (2°×1.5° rectangle) | 3.0 |
| PT1, PT2 (points) | 0 |
| LN1 (linestring) | 0 |
Geography Mode (spherical, returns square meters by default):
| Shape | Area (m² default, km² with UnitOfMeasure) |
|---|---|
| PY0 | ~157,650,000,000 m² (~157,650 km²) |
| PY1 | ~4,900,000,000 m² (~4,900 km²) |
| PY2 | ~36,800,000,000 m² (~36,800 km²) |
| PY3 | ~3,100,000,000 m² (~3,100 km²) |
| PY4 | ~36,900,000,000 m² (~36,900 km²) |
| PT1, PT2, LN1 | 0 (non-areal geometries) |
Units of Measure: For Geography types, the default unit is square meters. Use the SpatialArea(Column, UnitOfMeasure) constructor with UnitOfMeasure to specify alternative units such as square kilometers or square miles. The result is in the square of the specified linear unit (e.g., Kilometer returns km²).
| UnitOfMeasure | Result (GA: -100°,39° to -97°,41°, approx. 57,000 km²) |
|---|---|
| Meter | 57,000,000,000 |
| Kilometer | 57,000 |
| Mile | 22,007 |
| Foot | 613,542,300,000 |
| Yard | 68,171,370,000 |
| Inch | 88,350,120,000,000 |
Examples
Calculate the area of each land parcel stored as a geometry:
var schema = manager.LoadSchema("land");
var parcels = schema["parcels"];
var query = new Query()
.Select([ parcels["id"], new Expression("parcel_area", new SpatialArea(parcels["boundary"])) ])
.From(parcels);
var results = manager.Retrieve(query);
Constructors
- SpatialArea(Geometry)
Initializes a new instance of ST_Area for a geometry literal.
- SpatialArea(Column)
Initializes a new instance of ST_Area for a geometry column.
- SpatialArea(Column, UnitOfMeasure)
Initializes a new instance of ST_Area for a geography column with a unit of measure.
- SpatialArea(Function)
Initializes a new instance of ST_Area for a function result (e.g., from another spatial operation).
- SpatialArea(Function, UnitOfMeasure)
Initializes a new instance of ST_Area for a function result with a unit of measure.
- SpatialArea(Geography, UnitOfMeasure)
Initializes a new instance of ST_Area for a geography literal with a unit of measure.