Can you cast? No.
geometry
and geography
are PostGIS types, and your types are likely float
, double
, or something like that.
Can you create PostGIS types? Yes.
What you want to do is use ST_MakePoint(long,lat)
.
SELECT *,
ST_MakePoint(pickup_longitude, pickup_latitude) as pickup_pt,
ST_MakePoint(dropoff_longitude, dropoff_latitude) as dropoff_pt
If you don't have PostGIS.
- Get it. Install it. Use it:
CREATE EXTENSION postgis;
Or, if you can't get or have a good reason for not wanting it, then and only then should you even consider using the native type, point
.
SELECT *,
point(pickup_longitude, pickup_latitude) as pickup_pt,
point(dropoff_longitude, dropoff_latitude) as dropoff_pt
Geometery vs Geography
Geography to geometry conversions are a function to PostGIS. But you can do it with
SELECT ST_MakePoint(long,lat)::geography;
Or, you can use another geometery srid with
SELECT ST_SetSRID( ST_MakePoint(long,lat), srid );
CONCAT()
is a function that returns a text type as a result. If you want to combine 2 values (longitude and latitude) into a geometry type result, pick the appropriate function.