[postgis-users] creating a spatial index for finding objects withing a certaindistance in miles based on lat/lon
Paul Ramsey
pramsey at refractions.net
Fri Sep 12 09:59:31 PDT 2003
Daniel Ceregatti wrote:
> This is good news.
>
> The post you linked to seems to cover the "conversion from miles to
> degrees" in the query, but I still need to get my index built using
> degrees, where all I have are lat/lon. I think I saw something on the
> list regarding this, so I'll search further.
Daniel, lat/lon *are* degrees. Degrees are the units of a lat/lon data
set. You can pretend that lat/lon coordinates are planar for the
purposes of indexing and bounding box querying, and use the geodetic
distance function to directly measure distance off of them once you have
a result set. Thusly:
select * from tbl where geom && <LatLonBoundingBox> and
distance_spheroid(geom,<LatLonQueryPoint>,<Spheroid>) < <Radius>
I wonder if we should add in a "distance_sphere" for a less
computationally intensive conversion from lat/lon to distances than the
general spheroid case.
Paul
> Regarding Oracle, I'm not entirely sure how it does it either. I
> followed a simple "howto" like set of instructions that created the
> index based on lat/lon and was subsequently queryable using the sdo_*
> functions native to oracle, one of which was the sdo_within_distance ()
> mentioned earlier.
>
> Thanks for all your help, Paul and Chris.
>
> Daniel Ceregatti
>
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
More information about the postgis-users
mailing list