GeoDjango:如何根据点和半径创建圆 [英] GeoDjango: How to create a circle based on point and radius

查看:145
本文介绍了GeoDjango:如何根据点和半径创建圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下(简化的)模型:

I have the following (simplified) Model:

class Zone(gismodels.Model):
    name = gismodels.CharField()
    poly = gismodels.PolygonField()

我想基于给定的点和半径创建并保存代表圆形的多边形.

I want to create and save a polygon that represents a circle, based upon a given point and radius.

我能弄清楚如何实现此目标的唯一方法是使用原始SQL调用postgis ST_Buffer函数.我真的希望有另一种方法.

The only way I can figure out how to achieve this, is to call the postgis ST_Buffer function using raw SQL. I'm really hoping that there is another way.

是否可以访问GEOS缓冲方法?

Is it possible to access the GEOS buffer methods?

推荐答案

是的,可以使用此处的半径与点的坐标单位相同.这将对某些坐标系统(如UTM)有效,但不适用于其他坐标系.

The radius here is in the same units as the coordinates of the points. This will work for some coordinate systems like UTM, but not as well for others.

此外,虽然这适合于构造圆形几何体,但 PostGIS文档注释进行半径搜索ST_DWithin的效率更高.

Also, while this is appropriate for constructing a circular geometry, the PostGIS documentation notes that for doing radius searches ST_DWithin is more efficient.

这篇关于GeoDjango:如何根据点和半径创建圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆