[postgis-users] Need an answer for somebody new to GIS and PostGIS
Michael Fuhr
mike at fuhr.org
Sat Feb 3 14:10:04 PST 2007
On Sat, Feb 03, 2007 at 12:20:42PM -0800, Brent Wood wrote:
> We really need more info about your query & data to identify the problem, but
> as a quick guess, you are either not converting your units into appropriate map
> units, or are not using the appropriate distance function & projection.
A common problem is not realizing that coordinates are (X Y) and
therefore (lon lat). Using (lat lon) will usually yield incorrect
results. For example, the distance from San Francisco to Seattle
is approximately 677 miles:
SELECT distance_sphere('POINT(-122.4 37.8)', 'POINT(-122.3 47.6)') / 1609.344;
?column?
------------------
677.132056433782
(1 row)
If we put the coordinates in the wrong order then we get (incorrectly)
362 miles:
SELECT distance_sphere('POINT(37.8 -122.4)', 'POINT(47.6 -122.3)') / 1609.344;
?column?
------------------
362.066500885647
(1 row)
--
Michael Fuhr
More information about the postgis-users
mailing list