X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AEAF6D1B44B for ; Sat, 27 Dec 2003 00:10:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59277-10 for ; Fri, 26 Dec 2003 20:09:51 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 3F932D1B43C for ; Fri, 26 Dec 2003 20:09:48 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBR09o19008409; Fri, 26 Dec 2003 19:09:50 -0500 (EST) To: "Andy Lewis" Cc: pgsql-sql@postgresql.org Subject: Re: Radius of a zip code In-reply-to: <000b01c3cc09$e043fd70$0201a8c0@andy2> References: <000b01c3cc09$e043fd70$0201a8c0@andy2> Comments: In-reply-to "Andy Lewis" message dated "Fri, 26 Dec 2003 17:42:08 -0600" Date: Fri, 26 Dec 2003 19:09:49 -0500 Message-ID: <8408.1072483789@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/191 X-Sequence-Number: 16357 "Andy Lewis" 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