Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Geodjango+;波斯特吉斯。多边形总面积(平方米)_Python_Django_Gis_Postgis_Geodjango - Fatal编程技术网

Python Geodjango+;波斯特吉斯。多边形总面积(平方米)

Python Geodjango+;波斯特吉斯。多边形总面积(平方米),python,django,gis,postgis,geodjango,Python,Django,Gis,Postgis,Geodjango,我使用的是geodjango(3.1)+postgis,我希望以平方米为单位接收多边形的面积。因此,我正在使用 我的代码如下所示: City.objects.annotation(面积=面积('geom')) 我想我得到的结果是学位。当我用同样的方法,我得到了正确的结果平方米 当我将ST_Area(geom,use_spheroid=true)作为RawSQL执行时,结果也适合并以平方米为单位,但我希望避免使用RawSQL 谢谢你的帮助=)这对我很有用: City.objects.annotat

我使用的是geodjango(3.1)+postgis,我希望以平方米为单位接收多边形的面积。因此,我正在使用

我的代码如下所示:

City.objects.annotation(面积=面积('geom'))

我想我得到的结果是学位。当我用同样的方法,我得到了正确的结果平方米

当我将
ST_Area(geom,use_spheroid=true)
作为RawSQL执行时,结果也适合并以平方米为单位,但我希望避免使用RawSQL

谢谢你的帮助=)

这对我很有用:

City.objects.annotate(area=RawSQL("ST_AREA(geom, true)", []))
这对我很有用:

City.objects.annotate(area=RawSQL("ST_AREA(geom, true)", []))