470,647 Members | 1,268 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

gps to zipcode query: postgres or postgresql + postgis or how?

I would like to map from GPS coordinates to US Zipcode for US
Continental based needs.

(Yes, I am excluding perhaps Hawaii and Alaska for now, and I am also
assuming that a simple 2D geometry, assuming the GPS coordinates are
Euclidean and not spherically based will be good enough to find the
closest zip code.)

So assuming something simple like

create table zipcode (
zcode integer primary key,
loc point
);

I have the zipcode data from the postoffice and it contains lat, lon.
(As I'm sure you guys know....)

I notice that Postgresql already supports the point type. And I
figured how to enter points into the db.

What I haven't figured out how is to make a query that selects other
rows that are closed to my target.

select zcode from zipcode where loc ## 'userx, usery';

That seems to fail.

Can someone tell me:

A) Can I do this in postgresql without using postgis,
and if so, how? (and what indices should I create?)
B) Where a good reference to making queries with the
postgres native geometric types can be found?

I'm happy to use postgis, I just don't want to toss an a-bomb after a
fly. If I implement postgis and do this in postgis, would it be
faster than the "native" postgres query, and if so, why?

And how would I do this postgis and what sort of index would I need to
create?

And hell, all I need is a mapping the fastest way possible. Given
that I have the zipcode => (lat, lon) data, anyone know of any C code
to do a spatial search?

Thanks,
Jerry Asher
Jul 19 '05 #1
0 3478

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gregory S. Williamson | last post: by
3 posts views Thread by Stijn Vanroye | last post: by
reply views Thread by Lee Blevins | last post: by
2 posts views Thread by webhead74 | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.