Centroid of PolygonField

11 views
Skip to first unread message

Pasquale

unread,
Sep 12, 2019, 6:47:29 AM9/12/19
to django...@googlegroups.com
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?

Reply all
Reply to author
Forward
0 new messages