Use a function like this one:
select station_id, station_name, distance(stations_2.geom,(select geom
from stations_1 where station_id = 34)) as dist from stations_2 where
station_id <> 34 order by dist asc
hope this one speaks for itself, it returns a table ordered by distance,
from the nearest to the furthest, process the result in a view or something.
Good luck!
bdbeames schreef:
> 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.
>
--
Milo van der Linden
skype: milovanderlinden <skype:milovanderlinden?add>
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
http://www.3dsite.nl
De informatie in dit bericht reflecteert mijn persoonlijke mening en
niet die van een bedrijf of instantie. Aan de informatie kunnen geen
rechten worden ontleend. Indien dit bericht onderdeel is van een forum,
mailing-list of community dan gelden automatisch de bij het betreffende
medium behorende voorwaarden. The information in this message reflects
my personal opinion and not that of a company or public body. All rights
reserved.If this message is contained in a mailing-list or community,
the rights on the medium are automatically adapted.
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users