Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using mysql 5.1.50, so the distance QuerySet method is not available to me.

Here is my model:

class Location(models.Model):
    name = models.CharField(max_length='100')
    point = models.PointField(spatial_index=False)

    objects = models.GeoManager()

I would like to find all the locations where the point is within 5 miles of another point (eg. test_point). I've found some potential ways to do this but am unsure of all of them.


But it's not clear to me what the unit is for '1'. It looks like degrees. I can convert miles to degrees but it seems like there's a cleaner way to do this.

share|improve this question

You created a geo-model without expliciting the srid. This means that your geometries will default to 4326 (also known as WGS84, units are in degrees of longitude and latitude).

If you would be using PostGis < 1.5 for performing spatial queries using a distance like the buffer method does, you would need first to project your point to a projected system (most general is 900913, but there may be much better ones, depends on the zone of the world where your point is located), then create the buffered polygon, then reproject back the polygon to 4326, finally use this polygon in the within filter.

This should also apply to MySql, AFAIK.

If you would have the possibility of using PostGis 1.5, then you could create your model with geographic data type by using a GeometryField.geography option set to true [0]


share|improve this answer
I'm not using PostGIS at all. Nonetheless, I will explore the projection path a bit. – Adam Nelson Jan 21 '11 at 19:08
yep, I don't know MySql Spatial, but as I suggested the project-reproject strategy should work well ;) – capooti Jan 23 '11 at 22:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.