First Time here. Anyway, I have a database that I want to use to store user locations. I want to be able to get all the users with in say 15 miles. How do I do this. I'm using PostGIS 2.1. My SQL query is SELECT * FROM locations WHERE ST_DWithin(usercoord, ST_GeomFromText('POINT(%s %s)', 4326), %s) AND NAME!=%s;
usercoord is he geometry table with a SRID of 4326. I tried I'm using Python to execute the query. %s is just a place holder. The third %s is for the distance. I tried reading but I got even more confused. should the distance be in radians or should the distance be in km? I tried making it into radians. However, it didnt look like it worked. I put in 3959 in distance and got all of the users in then table. I have Users in Michigan, US and Pompei, Italy so that can't be in Km or Mi. But then I tried to convert the miles into radians and that didnt select the people with in 15 miles. So how should I get all the users with in x miles?
Saturday, 1 August 2015
python - Confused about ST_DWithin function postgis
Subscribe to:
Post Comments (Atom)
arcpy - Changing output name when exporting data driven pages to JPG?
Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...
-
I have a python script and I use it through my toolbox but I use it many times in a day. Is it possible to assign a keyboard shortcut to my ...
-
I want to implement a feature in my app (gmap powered) to highlight the area on mouse over. Much like the functionality in wikimapia. Check ...
-
I have some multi-spectral data, where the individual bands are separate Raster files. How do I layer stack these rasters so that I get one ...
No comments:
Post a Comment