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 shapely to check if a point is in a polygon, but I also need to check if a point is in a circle. Checking the docs, I don't see how do that...

Maybe I could create a circle?

circle = (x,y).buffer(R)

But it doesn't seem to work using R in miles distance to set the ratio...

Is it possible? Or is there another lib to get it?

share|improve this question
up vote 2 down vote accepted

Christian, you can't have your circle center and point in long,lat space and have R with mile units. Computational geometry algorithms require you to choose one coordinate system. Latitude and longitude is not a good one to work in, by the way unless your objects are very small in extent. After you transform your points to a local coordinate system and scale R to the units of that systems (meters, say), your test with shapely is like this:

Point(cx, cy).distance(Point(px, py)) <= R

where cx, cy is the center of your circle and px, py is your point. In units of the local coordinate system, not long/lat.

share|improve this answer
wow, you are right Sean... I'm working over it, Thanks.. – cespinoza Jan 15 '13 at 18:37

You can use the distance_lte function in geodjango to check if your point is in a circle or not. It is the same as ST_Distance method in PostGIS.

The method which I have mentioned is drawing a 5 meter radius of a circle to find points from Zipcode models.

Returns models where the distance to the geometry field from the lookup geometry is less than or equal to the given distance value.


Zipcode.objects.filter(poly__distance_lte=(geom, D(m=5)))

I hope it helps you...

share|improve this answer
Thanks Aragon, but not in all cases I have a zip code for the location, instead I need use a (latitude,longitude) format to set the point. – cespinoza Jan 10 '13 at 12:36
@Christian_Espinoza, this is an example code for you to seeing it how the function is using. you can create your own model from lon,lat to check them all. – Aragon Jan 10 '13 at 12:40

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.