I am fairly new to writing SQL and using PostGIS so apologies if this seems a bit simple or obvious. I have a table of polygon features held in a postGIS database and I need to write an SQL query to select all the attributes, the distance and the direction of the polygon features within a certain distance of a predefined point. I have managed to select the features and calculate the distance (using ST_Distance) but cannot work out how to obtain the bearing.
This is the script I am using so far:
SELECT *, ST_Distance (Geometry, ST_GeomFromText ('POINT(292596 90785)', 27700)) FROM mytable WHERE ST_DWithin( Geometry, ST_GeomFromText('POINT(292596 90785)', 27700), 250)
How do I work out the bearing of the features as well as the distance?