Re: Radius of a zip code

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andy Lewis" <jumboc(at)comcast(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Radius of a zip code
Date: 2003-12-27 00:09:49
Message-ID: 8408.1072483789@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Andy Lewis" <jumboc(at)comcast(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Travers 2003-12-27 02:14:40 Re: Anti log in PostgreSQL
Previous Message Andy Lewis 2003-12-26 23:42:08 Radius of a zip code