Centroid of PolygonField

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Centroid of PolygonField

Pasquale
I have the following model:

from django.contrib.gis.db import models as g


class Neighborhoods(Model):

    area = g.PolygonField()
   
    def point(self):
        #TODO:something better than this horrible hack of 2 db round trip
        return
Neighborhoods.objects.annotate(p=Centroid("area")).get(pk=self.id).p

How do I calculate point() without a 2nd roundtrip to the db?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2316c120-393a-b813-ee4c-a44916840e66%40gmail.com.