Is it possible to calculate distance on GeoDjango in a SELECT statement?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-03-31T00:59:59Z Indexed on 2010/03/31 1:03 UTC
Read the original article Hit count: 444

Filed under:
|
|
|
|

I am using MYSQL. I have a table with 1 column, a Point field.

I want to SELECT all rows that have a point with a distance less than 50 meters of my given point. Simple enough, right? Below is how it's done in RAW SQL. But of course, I want to use GeoDjango to do this.

cursor.execute("SELECT * FROM project_location WHERE\
(GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < 50)\

© Stack Overflow or respective owner

Related posts about geodjango

Related posts about python