[postgis-users] Selecting geocoded postal codes within a given distance ( miles for example )
Paul Ramsey
pramsey at refractions.net
Tue Dec 17 08:46:14 PST 2002
You have a couple options.
One is to take your whole data set and translate it into a planar
projection. If you have a contrained area, that might be a good thing to
do, because it makes the whole problem simpler.
Two is to essentially two-stage the problem. Problem (a) is subsetting
your complete data set to just those codes which *might* be within your
radius. Problem (b) is explicitly testing those codes. To do (b) on a
lat/lon data set, you need to know the ratio of miles/degrees longitude
and miles/degrees latitude for your area. You can calculate these with a
couple selects using length_spheroid and two-point LINESTRINGS
constructed in our search area. Then you use these distances to
construct a query box, and used distance_spheroid() to parse out just
those codes which fall in your search area.
You can see why option one is simpler :)
Hugh W. O'Brien wrote:
> Dear List,
>
> How would one go about selecting the geocoded postal codes within given
> a distance ( say in miles ) of another geocoded postal code. Finding
> the long/lat of the postal code we are searching around is simple ( no
> help is needed there ). I have read/seen the faq for postgis. The
> example given there using a bounding box doesn't really fit what I am
> trying to do exactly because I will be dealing with degrees
> longitude/latitude and miles ( the example in the faq uses meters
> exclusively ).
>
> Thanks in advance for any help you can give.
>
> -- Hugh W. O'Brien
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
More information about the postgis-users
mailing list