In the query below I am exporting only the endpoint of linestrings in my table
routes to a json file.
My objective, however, is to export to a csv, with four separate columns -
ogr2ogr -f GeoJSON endpoints.json "PG:host=localhost dbname=dbname user=user password=password" -sql "SELECT ST_AsText(ST_EndPoint(path::geometry)) from routes"
How could I change the query in psql below to include latitude and longitude of the endpoints as separate columns, using
\COPY ( SELECT starttime, endtime, lat, lon from routes ) TO 'endpoints.csv' WITH CSV HEADER DELIMITER ',';