Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Points
Linestrings
Polygons
Summary

Instruction

Perfect! Next, let's get to know a couple functions that will be useful when we work with linestrings. The first two are ST_StartPoint(geometry) and ST_EndPoint(geometry). Take a look at how they're used:

SELECT 
  ST_AsText(ST_StartPoint(course)), 
  ST_AsText(ST_EndPoint(course)) 
FROM sf_selected_railways 
WHERE id = 1;

In the query above, we show the start and end point of the railway with id = 1. Note that we used ST_AsText(...) and passed in ST_StartPoint(...) as its argument. That's because ST_StartPoint and ST_EndPoint return points in the internal PostGIS format, which is not very human-readable. Thus, we used ST_AsText(...) to convert it to WKT.

As you can tell, spatial functions can be nested, or put inside one another.

Exercise

Show the start points (in the WKT format) of all bicycle routes in the table sf_bicycle_routes that have a condition_rating of 2.

Stuck? Here's a hint!

Use ST_StartPoint inside ST_AsText to get the WKT representation of the start points.