[postgis-users] Indices for ST_distance_sphere

Paul Ramsey pramsey at cleverelephant.ca
Tue Oct 14 17:43:53 PDT 2008


Want to quantify distortion?

Compare

select st_distance_spheroid(spheroid, pt1, pt2);

with

select st_distance(st_transform(pt1, srid), st_transform(pt2, srid))

For bonus marks, do it to a grid over your whole domain area, so you
can see the pattern of variation. Widely spaced points will have
larger variance than close ones, but whether you care depends, again,
on your actual use cases.

P

On Tue, Oct 14, 2008 at 5:40 PM, Paul Ramsey <pramsey at cleverelephant.ca> wrote:
> If you're in a planar projection, then
>
> select * from footable where st_dwithin(the_geom, 'POINT(foo bar)', DISTANCE)
>
> will return based on an indexed search for arbitrary foo and bar. You
> need to be in a planar projection so the spatial index works in the
> same cartesian domain as the distance calculation.
>
> Every planar projection introduces distance/area distortion, the
> question is "do you care". Is it big enough to be concerned about,
> given your use case.  Variance of +/- 1cm in questions that are need
> 10m accuracy aren't important.
>
> P.
>
> On Tue, Oct 14, 2008 at 5:31 PM, Stephen Baillie
> <steve at alliancesoftware.com.au> wrote:
>>
>>> What about 3112 (# GDA94 / Geoscience Australia Lambert) or 3577
>>> (Australian Albers), those should cover things fine, no?
>>>
>>
>> Possibly, although I'm finding it hard to find hard data on what those
>> actually mean (let alone what other alternatives are supported by PostGIS).
>>  It looks like they still produce range distortion, which answers to my
>> previous question on this list gave me to believe would be a problem for
>> anything except true spherical distances.
>>
>> Closer to the point, though, the choice of projection is of lesser
>> importance to my question than that of indexing.  PostgreSQL tells me that
>> the spherical distance calculations increase full table scan time by about
>> two-thirds when I use those as the where clause of my search instead of
>> using a lat/long bounding box, but my question is actually about indexing
>> before doing such distance calculations:
>>
>> Is it possible to create an index that can be used to speed searches based
>> on distance from an arbitrary point, or should I just use a lat/long
>> bounding box?
>>
>> Thanks,
>>
>> Steve.
>>
>> --
>> Stephen Baillie
>> Developer
>> Alliance Software
>>
>> 1/234 Whitehorse Road
>> Nunawading, VIC 3131
>> Australia
>>
>> Ph:  03 9877 9921
>> Fax: 03 9894 2106
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>



More information about the postgis-users mailing list