[postgis-users] Latitude and longitude distances

Bill Binko bill at binko.net
Wed Jul 27 11:53:18 PDT 2005


On Wed, 27 Jul 2005, Vacuum Joe wrote:

> Thanks for the scoop on that Ethan.
> 
> What I will probably do then is not use PostGIS at
> all, but just do this all in native Postgres. 
> Fortunately for me I don't care about the polar
> regions too much, so I can make some approximations to
> use a "box" to narrow down my sets that I have to do
> actual distance calculations on.  I already have the
> formula for calculating distances between lat/lon
> pairs so I'll just use that.  Fortunately also there
> aren't too many data points at this stage.
> 
> Thanks for your help.
> 
> 
...

> >  If all your points say fall within a UTM zone or a state plane
> > coordinate system then you could get away with just projecting all
> > your data into the appropriate projection.
> > 

Joe, I would recommend this approach: I have used it extensively and it 
works well.  Loading the data is fairly easy (I write command line scripts 
in PHP that load the lat/long into PostGIS Points, but there are other 
options with ogr2ogr etc).  Then you can use the transform() function to 
convert those points from lat/lon to whatever fits the data best.

I know this sounds like work, but once you have the data in there, you can 
do magic stuff using all of PostGIS's spatial relationship functions and 
indexes.

Bill