Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Call me stupid, but somehow I couldn't figure out how to do the following.

I've got a testing shapefile with 18 features, which I successfully imported into GeoDjango (1.3, running on Spatialite). As an practical example, I've taken a centroid of one of them (area.mpoly.centroid) and tried to find all areas within a 20 km distance (touching would be enough, needn't cover complete area).

Area.objects.filter(mpoly__dwithin=(centroid, D(km=20)))

However, this only gives me an empty list. Increasing the number to 200 km (in theory, this should cover all of my dataset) also yields nothing.

Am I doing something wrong?

share|improve this question
    
If you're trying to do this in ArcGIS prior to the import, I believe you want to write a command to make a 20 km buffer around your points, then do an intersect between the polygon layer and your buffer. Sorry, I don't know any programming, but that's how I'd do it using tools in ESRI. Does that help at all? –  Dano Aug 12 '11 at 14:24
    
@Dano: no, sorry, I need to do this in GeoDjango. –  Nikolai Prokoschenko Aug 12 '11 at 14:29
add comment

1 Answer 1

I missed this before, you're using SpatialLite. dwithin is not supported with SpatialLite.


Old answer: 'Area' is a GeoDjango class. You probably have a name conflict. Don't name your models with the same name of any GeoDjango classes.

Also, 'centroid' should not be used as a variable name for the same reason.

share|improve this answer
1  
code above is not the exact copy of my code, I've changed the specific model name to Area, likewise with centroid, both shouldn't be a problem as long as the imports are correct. It's not a naming conflict. –  Nikolai Prokoschenko Aug 14 '11 at 11:42
add comment

Your Answer

 
discard

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.