Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need specific configuration for Spatialite with GeoDjango?

According to https://docs.djangoproject.com/en/1.3/ref/contrib/gis/db-api/, Spatialite supports GeoQuerySet.distance(). However, having imported an area list (MultiPolygon as mpoly attribute), I'm trying to do the following:

Area.objects.all().distance(center)

And instead of something usable, I only get an error message: "ValueError: SQLite does not support linear distance calculations on geodetic coordinate systems."

What's wrong here, do I need some special configuration on Spatialite or is the documentation plain wrong?

like image 852
Nikolai Prokoschenko Avatar asked Aug 12 '11 13:08

Nikolai Prokoschenko


1 Answers

You don't need to do anything regarding spatialite, but rather change the coordinate system (srid) you're using. Spatialite does distance calculations only on geographic coordinate systems, not geodetic. Check the SRID do you have in your model definition. Alternatively you can also switch to the postgis backend.

like image 187
brutasse Avatar answered Nov 15 '22 04:11

brutasse