Table of Contents

Class SpatialLength

Namespace
YndigoBlue.Velocity.Functions
Assembly
YndigoBlue.Velocity.dll

Represents the ST_Length spatial measurement function that computes the length of a linear geometry.

public class SpatialLength : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
Inheritance
SpatialLength
Implements

Remarks

Warning

Spatial functions are not available in the Community Edition of Velocity. They require the Full Edition.

The ST_Length function returns the total length of a linestring or multi-linestring geometry. For polygons, it may return the perimeter. For points, typically returns 0. For Geometry types, length is in coordinate system units. For Geography types, length is calculated using spherical geometry and can be specified with a unit of measure (meters, kilometers, miles, etc.). This is useful for measuring distances, calculating route lengths, or analyzing linear features. OGC-compliant.

SpatialLength diagram showing line measurements

Return Type: Numeric (float/double). Units depend on coordinate system or specified UnitOfMeasure.

Length by Geometry Type:

Input TypeLength Result
POINT0 (no length)
LINESTRINGTotal length of the line
Multi-segment LINESum of all segment lengths
POLYGONPerimeter (sum of ring lengths)
MULTILINESTRINGSum of all line lengths

Example Results (using test geometries):

ShapeLength (in degrees)
LN1 (vertical, 2° tall)2.0
Diagonal line (2°×2°)~2.83 (√8)
Multi-segment lineSum of segment lengths
Polygon (perimeter)Sum of all edges
PT1 (point)0

Units of Measure: For Geography types, use UnitOfMeasure to get results in meters, kilometers, miles, or other supported units.

SpatialLength Geography diagram showing great-circle route length with UnitOfMeasure

UnitOfMeasureResult (Route A at -102°,37° via M at -99°,40° to B at -96°,43°, approx. 840 km)
Meter840,000
Kilometer840
Mile522
Foot2,755,906
Yard918,635
Inch33,070,860

Examples

Calculate the length of each road segment in the network:

var schema = manager.LoadSchema("infrastructure");
var roads = schema["roads"];

var query = new Query()
    .Select([ roads["id"], roads["name"], new Expression("segment_length", new SpatialLength(roads["path"])) ])
    .From(roads);

var results = manager.Retrieve(query);

Constructors

SpatialLength(Geometry)

Initializes a new instance of ST_Length with a geometry literal.

SpatialLength(Column)

Initializes a new instance of ST_Length with a geometry column.

SpatialLength(Column, UnitOfMeasure)

Initializes a new instance of ST_Length with a geography column and unit of measure.

SpatialLength(Function)

Initializes a new instance of ST_Length for a function result (e.g., from another spatial operation).

SpatialLength(Function, UnitOfMeasure)

Initializes a new instance of ST_Length for a function result with a unit of measure.

SpatialLength(Geography, UnitOfMeasure)

Initializes a new instance of ST_Length with a geography literal and unit of measure.