[OSM-dev] projection for calculating distances in PostGIS

Marcus Wolschon Marcus at Wolschon.biz
Wed May 19 13:26:35 BST 2010


On Wed, May 19, 2010 at 2:13 PM, Emilie Laffray
<emilie.laffray at gmail.com> wrote:
>
>
> On 19 May 2010 13:06, Marcus Wolschon <Marcus at wolschon.biz> wrote:
>>
>> Hello,
>>
>> what projections do you use to calculate distances (in meters) in postgis?
>> I have some code here that tried to use 27700 but that is not defined
>> on all inhabited continents of this planet.
>> An error of at most 25% would be acceptable as tis is just about search
>> -areas and not street-length.
>
>
> It all depends what kind of distance you are trying to get. One easy way is
> to use the FindUTM of the area you are looking for
> http://trac.osgeo.org/postgis/wiki/UsersWikiplpgsqlfunctionsDistance
>
> The next possible trick is to switch your column type to geography if you
> have postgis 1.5. It would mean that all postgis function relating to length
> and areas would start reporting data in meters.

It is postgis 1.4 and the data-columns are geometries in WGS84 with
the bounding-boxes
stored pre-computed and projected in their own column, for faster access.

The page you mentioned has a ST_DWithin_Sphere but that only works
between 60 and -60° and it does not help with the distance-calculation
required for
sorting the results by distance (I forgot to mention that. This is
about finding the closest
element to a search-point where the elements may be points, lines and areas.).
This code needs to work on all of the continental planet except north
and south polar
regions. (60,60 is still somewhere in russia).

So the question is just to find a better projection to use.
Due to locality it would even be possible to use different projections
based on WGS84-
coordinate-regions.

Marcus




More information about the dev mailing list