[Fixed]-GeoDjango – lon/lat PointFields distance are using geometry instead of geography

1👍

Reading through the documentation I found that this distance calculation in the GEOSGeometry class does not respect the SRID and is different than the one provided directly by the PostGIS database.

I used the python libray geopy which provides the distance method for calculating distance.

from geopy.distance import distance as geopy_distance
geopy_distance(customer1.gis_location, customer2.gis_location).kilometers

Unfortunately I still can’t figure out how to do a distance calculation with two Points using Django’s GIS library.

Leave a comment