first_point
geometric-functions first_point
The first_point function extracts the first point from each sequence (arc, polygon, or linestring).
syntax
first_point(sequences: E->Sequence<Point>) -> E->Point
definition
Returns the first point of each sequence geometry. For:
- Arcs/linestrings: The starting point of the line
- Polygons: The first vertex (which equals the last vertex for closed rings)
- Empty sequences: Returns undefined (null)
This is the counterpart to last_point.
arguments
| argument | description | type |
|---|---|---|
| sequences | Attribute containing sequence geometries | E->Sequence |
performance
Time complexity: O(n) where n is the number of sequences (constant time per sequence).
Memory efficient as it only accesses the first element of each sequence without loading entire geometries.
conditions
- Input must be a sequence type (arc, polygon, linestring)
- Result is undefined for empty sequences
example
unit<uint32> Roads: nrofrows = 100;
attribute<FPoint> geometry (poly, Roads); // road linestrings
// Get start and end points of each road
attribute<FPoint> start_point (Roads) := first_point(geometry);
attribute<FPoint> end_point (Roads) := last_point(geometry);
// Check if roads form closed loops
attribute<Bool> is_closed (Roads) := start_point = end_point;
see also
- last_point - extracts last point
- sequence2points - extracts all points from sequences
- centroid - center of mass of geometry
- geometric-functions
- sequence-functions
since version
5.0