Set SRID in View From XY Data

260 Views Asked by At

Trying to create a view that joins two tables, converts XY coord data into a sinlge spatial point, and sets the SRID value. I've got it all working except for the SRID command. I can't use pre assigned coordinates to do a transform as I'm generating multiple results. Any help would be appreciated!

CREATE  VIEW V_Station_Locations AS
      SELECT S.station_id, S.station_name, 
           ST_MakePoint(V.x_coord, V.y_coord)
           ST_SetSRID(ST_Point(x_coord, y_coord),28350)
 FROM  STATION S
 INNER JOIN SUBURB_VERTEX V ON (S.vertex_id=V.vertex_id)
1

There are 1 best solutions below

1
On

Just move the st_setSRID up:

CREATE  VIEW V_Station_Locations AS
      SELECT S.station_id, S.station_name, 
           ST_SetSRID(ST_MakePoint(V.x_coord, V.y_coord),28350) as geom
 FROM  STATION S
 INNER JOIN SUBURB_VERTEX V ON (S.vertex_id=V.vertex_id)