[postgis-users] -- Caculating distance from an address --

Rafael Orta rorta_us at yahoo.com
Fri Sep 15 07:48:12 PDT 2006


Hello Everybody
 
I am new to Postgress and PostGIS and will appreciate your help with the following.
I have a table with addresses and the geocode from the addresses (latitude / longitude). I need
to look for the properties in my table less than 100 meters from a point.
 
TABLE CREATION
----------------------
create table smarter.vow_properties (property_id serial, address varchar(150), latitude numeric (7,4) , longitude numeric (7,4))
select AddGeometryColumn('smarter','vow_properties','geom',-1,'POINT',2);
 
TABLE POPULATION
------------------------
insert into smarter.vow_properties(address, latitude, longitude) values ('12 LONG BRIDGE DR,MOUNT LAUREL, NJ 08054','39.940252','-074.921916');
insert into smarter.vow_properties(address, latitude, longitude) values ('6 LONG BRIDGE DR, MOUNT LAUREL, NJ 08054','39.939777','-074.922529');
insert into smarter.vow_properties(address, latitude, longitude) values ('12 BARTON WAY, MOUNT LAUREL, NJ 08054','39.940323','-074.920154');
insert into smarter.vow_properties(address, latitude, longitude) values ('12 ETNA CT, MOUNT LAUREL, NJ 08054','39.943422','-074.920035');
insert into smarter.vow_properties(address, latitude, longitude) values ('25 BIDDLE WAY, MOUNT LAUREL, NJ 08054','39.941696','-074.921379');
insert into smarter.vow_properties(address, latitude, longitude) values ('4 CARLISLE CT, MOUNT LAUREL, NJ 08054','39.937971','-074.919323 ');
insert into smarter.vow_properties(address, latitude, longitude) values ('25 ANN DR, MOUNT LAUREL, NJ 08054','39.940312','-074.915664 ');
insert into smarter.vow_properties(address, latitude, longitude) values ('25 FARMHOUSE LN, MOUNT LAUREL, NJ 08054','39.946788','-074.905868');
insert into smarter.vow_properties(address, latitude, longitude) values ('25 RALEIGH DR, MOUNT LAUREL, NJ 08054','39.940080','-074.911597 ');
insert into smarter.vow_properties(address, latitude, longitude) values ('11 ELDERBERRY CT, MOUNT LAUREL, NJ 08054','39.946788','-074.905868');

Updating the geom column
=====================
update smarter.vow_properties set geom = makePoint (latitude, longitude);
 
Looking for properties in my table that are around 100 metters from a point.
==================================================
select * from smarter.vow_properties where geom && Expand(GeomFromText('POINT( 39.940252 -074.905868)',-1),100)
and Distance (GeomFromText('POINT(39.946788 -074.905868)',-1),geom) < 100;
 
What I am doing wrong? No matter what distance I place even 1 metter it return all the rows.
 
32;"12 LONG BRIDGE DR,MOUNT LAUREL, NJ 08054";39.9403;-74.9219;"0101000000E3361AC05BF84340AC8BDB6800BB52C0"
33;"6 LONG BRIDGE DR, MOUNT LAUREL, NJ 08054";39.9398;-74.9225;"0101000000F163CC5D4BF84340D7A3703D0ABB52C0"
34;"12 BARTON WAY, MOUNT LAUREL, NJ 08054";39.9403;-74.9202;"0101000000E3361AC05BF84340DE718A8EE4BA52C0"
35;"12 ETNA CT, MOUNT LAUREL, NJ 08054";39.9434;-74.9200;"0101000000F085C954C1F843407B14AE47E1BA52C0"
36;"25 BIDDLE WAY, MOUNT LAUREL, NJ 08054";39.9417;-74.9214;"0101000000545227A089F8434034A2B437F8BA52C0"
37;"4 CARLISLE CT, MOUNT LAUREL, NJ 08054";39.9380;-74.9193;"0101000000F2D24D6210F843409FCDAACFD5BA52C0"
38;"25 ANN DR, MOUNT LAUREL, NJ 08054";39.9403;-74.9157;"0101000000E3361AC05BF843409F3C2CD49ABA52C0"
39;"25 FARMHOUSE LN, MOUNT LAUREL, NJ 08054";39.9468;-74.9059;"010100000029ED0DBE30F94340925CFE43FAB952C0"
40;"25 RALEIGH DR, MOUNT LAUREL, NJ 08054";39.9401;-74.9116;"01010000001C7C613255F8434027C286A757BA52C0"
41;"11 ELDERBERRY CT, MOUNT LAUREL, NJ 08054";39.9468;-74.9059;"010100000029ED0DBE30F94340925CFE43FAB952C0"

 
Thanks in advance
 
Rafael Orta


***************************************************** 
Rafael Orta                                  Phone: (609)-330-3193 
Sr. Oracle DBA                            Fax: (856)-642-7679 
Technical Manager 
Oraprofessionals                          Email: rorta_us at yahoo.com 
******************************************************
 		
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060915/6840000a/attachment.html>


More information about the postgis-users mailing list