GEOS django API 中的缓冲区将使用您当前坐标系统使用的任何单位创建缓冲区。
如果您将所有内容存储在 4326 中(以纬度/经度为单位),那么您将不得不找到一些将 KM 转换为度数的棘手方法。但是现在你越往北走,你的缓冲区就会严重扭曲。
更好的解决方案是将几何图形重新投影到保持面积的投影中,并且通常这种投影可以跟踪以米为单位的单位。
例如,如果您在北美创建缓冲区,您可以使用这个使用米的投影http://spatialreference.org/ref/sr-org/7314/
这是一个如何使用 Django GEOS API 的示例:
from django.contrib.gis.geos import Point
# Defines a point in lat/long
p = Point(-70, 50)
# This projection defines lat/long coordinate system
p.srid = 4326
# Transform into the 7314 projection using the OGC WKT format to define that projection
p.transform('PROJCS["NA Lambert Azimuthal Equal Area",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["false_easting",0.0],PARAMETER["false_northing",0.0],PARAMETER["longitude_of_center",-100.0],PARAMETER["latitude_of_center",45.0],UNIT["meter",1.0]]')
# Creates a buffered polygon of 1000 meters in radius
poly = p.buffer(1000)