通过添加中间点将多边形或多多边形的平面边缘转换为测地线。Converts polygon or multipolygon planar edges to geodesics by adding intermediate points.


geo_polygon_densify(polygon, tolerance)geo_polygon_densify(polygon, tolerance)


  • polygon:采用 GeoJSON 格式dynamic 数据类型的多边形或多多边形。polygon: Polygon or multipolygon in the GeoJSON format and of a dynamic data type.
  • tolerance:一个可选数值,用于定义原始平面边缘与转换后的测地线边缘链之间的最大距离(以米为单位)。tolerance: An optional numeric that defines maximum distance in meters between the original planar edge and the converted geodesic edge chain. 支持的值范围为 [0.1, 10000]。Supported values are in the range [0.1, 10000]. 如果未指定,则使用默认值 10If unspecified, the default value 10 is used.


采用 GeoJSON 格式dynamic 数据类型的致密多边形。Densified polygon in the GeoJSON format and of a dynamic data type. 如果多边形或公差无效,则查询会生成 null 结果。If either the polygon or tolerance is invalid, the query will produce a null result.


  • 对按照 WGS-84 坐标参考系统表示的地理空间坐标进行解释。The geospatial coordinates are interpreted as represented by the WGS-84 coordinate reference system.
  • 必须正确定义多边形,但此函数并不检查多边形有效性。The polygon must be correctly defined, but the function does not check polygon validity.

多边形定义Polygon definition

dynamic({"type":"Polygon","coordinates": [ LinearRingShell, LinearRingHole_1 ,..., LinearRingHole_N ]})dynamic({"type": "Polygon","coordinates": [ LinearRingShell, LinearRingHole_1 ,..., LinearRingHole_N ]})

dynamic({"type":"MultiPolygon","coordinates": [[ LinearRingShell, LinearRingHole_1 ,..., LinearRingHole_N ] ,..., [LinearRingShell, LinearRingHole_1 ,..., LinearRingHole_M]]})dynamic({"type": "MultiPolygon","coordinates": [[ LinearRingShell, LinearRingHole_1 ,..., LinearRingHole_N ] ,..., [LinearRingShell, LinearRingHole_1 ,..., LinearRingHole_M]]})

  • LinearRingShell 是必需的,定义为 counterclockwise 有序坐标数组 [[lng_1,lat_1],...,[lng_i,lat_i],...,[lng_j,lat_j],...,[lng_1,lat_1]]。LinearRingShell is required and defined as a counterclockwise ordered array of coordinates [[lng_1,lat_1],...,[lng_i,lat_i],...,[lng_j,lat_j],...,[lng_1,lat_1]]. 只能有一个 shell。There can be only one shell.
  • LinearRingHole 是可选的,定义为 clockwise 有序坐标数组 [[lng_1,lat_1],...,[lng_i,lat_i],...,[lng_j,lat_j],...,[lng_1,lat_1]]。LinearRingHole is optional and defined as a clockwise ordered array of coordinates [[lng_1,lat_1],...,[lng_i,lat_i],...,[lng_j,lat_j],...,[lng_1,lat_1]]. 可以有任意数量的内部环和孔。There can be any number of interior rings and holes.
  • LinearRing 顶点必须很独特,至少有三个坐标。LinearRing vertices must be distinct with at least three coordinates. 第一个坐标必须等于最后一个坐标。The first coordinate must be equal to the last. 至少需要四个条目。At least four entries are required.
  • 坐标 [经度,纬度] 必须有效。Coordinates [longitude,latitude] must be valid. 经度必须是 [-180, +180] 范围内的实数,纬度必须是 [-90, +90] 范围内的实数。Longitude must be a real number in the range [-180, +180] and latitude must be a real number in the range [-90, +90].
  • LinearRingShell 最多包含球体的一半。LinearRingShell encloses at most half of the sphere. LinearRing 将球体分成两个区域。LinearRing divides the sphere into two regions. 将选择这两个区域中较小的一个。The smaller of the two regions will be chosen.
  • LinearRing 边缘长度必须小于 180 度。LinearRing edge length must be less than 180 degrees. 将选择两个顶点之间的最短边缘。The shortest edge between the two vertices will be chosen.


  • 致密多边形的最大点数限制为 10485760。The maximum number of points in the densified polygon is limited to 10485760.
  • dynamic 格式存储多边形有大小限制。Storing polygons in dynamic format has size limits.
  • 致密化有效多边形可能会使其无效。Densifying a valid polygon may invalidate it. 此算法以非均匀的方式添加点,因此可能导致边缘彼此缠绕。The algorithm adds points in a non-uniform manner and as such may cause edges to intertwine with each other.


  • GeoJSON 格式将两点之间的边定义为直笛卡尔线。GeoJSON format defines an edge between two points as a straight cartesian line.
  • 是使用测地线还是平面边缘可能取决于数据集,在长边中尤其如此。The decision to use geodesic or planar edges might depend on the dataset and is especially relevant in long edges.


以下示例致密化曼哈顿中央公园多边形。The following example densifies Manhattan Central Park polygon. 这些边缘较短,平面边缘与其对应的测地线之间的距离小于公差规定的距离。The edges are short and the distance between planar edges and their geodesic counterparts is less than the distance specified by tolerance. 因此,结果保持不变。As such, the result remains unchanged.

print densified_polygon = tostring(geo_polygon_densify(dynamic({"type":"Polygon","coordinates":[[[-73.958244,40.800719],[-73.949146,40.79695],[-73.973093,40.764226],[-73.982062,40.768159],[-73.958244,40.800719]]]})))

以下示例致密化多边形的两条边。The following example densifies two edges of the polygon. 致密化后的边长度约为 110 公里Densified edges length is ~110 km

print densified_polygon = tostring(geo_polygon_densify(dynamic({"type":"Polygon","coordinates":[[[10,10],[11,10],[11,11],[10,11],[10,10]]]})))

下面的示例由于坐标输入无效而返回 null 结果。The following example returns a null result because of the invalid coordinate input.

print densified_polygon = geo_polygon_densify(dynamic({"type":"Polygon","coordinates":[[[10,900],[11,10],[11,11],[10,11],[10,10]]]}))

下面的示例由于公差输入无效而返回 null 结果。The following example returns a null result because of the invalid tolerance input.

print densified_polygon = geo_polygon_densify(dynamic({"type":"Polygon","coordinates":[[[10,10],[11,10],[11,11],[10,11],[10,10]]]}), 0)