pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andy Lewis <jumboc@comcast.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Radius of a zip code
Date: Fri, 26 Dec 2003 19:09:49 -0500
Message-ID: <8408.1072483789@sss.pgh.pa.us> (raw)
In-Reply-To: <000b01c3cc09$e043fd70$0201a8c0@andy2>
References: <000b01c3cc09$e043fd70$0201a8c0@andy2>

"Andy Lewis" <jumboc@comcast.net> writes:
> I was trying to find all zip codes within a given zip code or radius.

I think there are canned solutions for this available in PostGIS ---
have you looked at that?

> I've tried the following with no luck:
 
> -- 20 Miles
> --select 20 * 360.0 / (7900.0 * atan2(1,1) * 4.0);
> select * from zip_code where map_loc @
> circle(map_point('dallas','tx','75201'), .290105212724467 ) order by
> city

I'm guessing that the big problem is that you didn't measure longitude
and latitude in identical units in your table, so your "circle" isn't
real circular, and the smaller problem is that "miles" converts to
"degrees of arc" differently at different latitudes.

			regards, tom lane



view thread (10+ messages)  latest in thread

Message-ID: <8408.1072483789@sss.pgh.pa.us>
Permalink:  ../8408.1072483789@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8408.1072483789@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jumboc@comcast.net
  Subject: Re: Radius of a zip code
  In-Reply-To: <8408.1072483789@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox