Hey folks,
I am trying to use the 'Area' function documented here:
https://docs.djangoproject.com/en/1.10/ref/contrib/gis/functions/#area to
annotate my geo queryset results with Area of the polygon geometries in my
database.
This works great with something like:
annotated_qset = GeoModel.objects.annotate(area=Area('geom'))
I then have a property called 'area` which I can use and it's all great.
However, I then try and filter by Area by following the documentation for
filtering by Length on the documentation page, so I try something like:
filtered_qset =
GeoModel.objects.annotate(area=Area('geom')).filter(area__gt=1)
This gives an error like "AttributeError: 'AreaField' object has no
attribute 'get_lookup".
It makes sense that this works for the Length function since Length uses
the FloatField class, so supports lookups and filters, whereas the
AreaField does not:
https://github.com/django/django/blob/master/django/contrib/gis/db/models/sql/conversion.py#L24
I could be totally naive here and this may just not be a trivial thing for
the back-end (PostGIS in my case) to support, but just wondering if anyone
has any work-arounds to filter by area size of feature, and / or if there
are plans to support this in future versions.
Thank you all again for an amazing community and amazing piece of software
:-)
-Sanjay
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAG3W7ZHq4BtoAGwgQxNaXWG4ofYGGPwm1c4R4u6AFxCQMOUceQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.