【问题标题】:GeoDjango: How to get area of all object in a model?GeoDjango:如何获取模型中所有对象的面积?
【发布时间】:2014-09-09 06:20:43
【问题描述】:

我们可以通过这个得到特定引脚的面积:

>>> from tbl.models import *
>>> from django.contrib.gis.geos import *
>>> pnt = ButuanMaps.objects.get(clandpin='162-03-0001-017-33').geom
>>> pnt = ButuanMaps.objects.get(clandpin='162-03-0001-017-33')
>>> pnt = ButuanMaps.objects.get(clandpin='162-03-0001-017-33').geom
>>> pnt.area
4947.0185203032115

如何获取所有引脚的所有区域?

【问题讨论】:

    标签: area geodjango


    【解决方案1】:

    我是这样做的:

    >>> distincts = ButuanMaps.objects.order_by('id').values_list('clandpin', flat=True)[:10]
    >>> for value in distincts:print (reduce(lambda a,x: x.calculated_area.sq_m, ButuanMaps.objects.filter(clandpin=value).area(model_att='calculated_area'), Area(0)),value)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-06
      • 2022-12-01
      • 2011-01-15
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      相关资源
      最近更新 更多