« Return to Thread: Spatial query for the Nearest location given a lat and long?

Spatial query for the Nearest location given a lat and long?

by bdbeames :: Rate this Message:

Reply to Author | View in Thread

I'm completely new to this so I need some help writing a query.

What I have is two tables with weather station information: id, name, latitude, longitude, extra.

I am using google map where a user can click on a station from one of the tables, I obtain the $latitude and $longitude points of that location.  I now want to use these to find the nearest weather station in my other table based on the $latitude and $longitude point.

All that I need back from the query is the id and name of the nearest station.  Could someone help me write a simple query to do this.

My development environment is Linux/Apache/Postgres/php.

Thanks.

 « Return to Thread: Spatial query for the Nearest location given a lat and long?