function st_distancesphere(geometry, geometry) does not exist?

585 views
Skip to first unread message

Richard Belew

unread,
Sep 28, 2020, 2:21:02 PM9/28/20
to geodjango

hi all,  using django 3.0.7, and have a (new) issue filtering on objects with point attributes within a distance of another point?  my filter looks like this: 

     .filter(point__distance_lte=(dlPt, D(m=CloseRadius)))

i can build a query set using this filter, but when it invokes the postgres query it builds a (postgres) query that looks like this:

    SELECT "objectName"."idx", "objectName"."rd", ... WHERE ST_DistanceSphere("objectName"."point", ST_GeomFromEWKB(\'\\001\\001\\000\\000 \\346\\020\\000\\000!\\345\\314\\033L\\214^\\300\\314\\262\'\'\\201\\315\\341B@\'::bytea)) <= 500.0)

and I get this error: 

    django.db.utils.ProgrammingError: function st_distancesphere(geometry, geometry) does not exist

dlPt is a Point:

    type(dlPt)
    >>> <class 'django.contrib.gis.geos.point.Point'>

and the objects being filtered have the same type `point`.

Thanks for any clues you might have.  - Rik


Emanuele Di Giacomo

unread,
Sep 29, 2020, 1:59:30 AM9/29/20
to geod...@googlegroups.com
Hi Rik,
maybe your PostGIS version is too old? Reading
https://postgis.net/docs/ST_DistanceSphere.html, it seems that the
function was renamed from ST_Distance_Sphere to ST_DistanceSphere in
PostGIS 2.2.0.
> --
> You received this message because you are subscribed to the Google Groups "geodjango" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to geodjango+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/cb9b3dea-82a8-442b-872f-dab8cd4a144en%40googlegroups.com.

Richard Belew

unread,
Sep 29, 2020, 11:52:47 AM9/29/20
to geodjango
Thanks Emanuele,  it does seem my issue is due to the version of PostGIS  I have:  SELECT PostGIS_Version() returns: "2.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1".
Reply all
Reply to author
Forward
0 new messages