MEASUREMENT
COORDINATE MUTATION
TRANSFORMATION
FEATURE_CONVERSION
MISC
HELPER
RANDOM
GRIDS
AGGREGATION
META
ASSERTIONS
BOOLEANS
UNIT CONVERSION
DATA
JOINS
CLASSIFICATION

pointGrid

pointGrid函数用于在指定区域内生成网格状的点集。该函数的结果为一组表示网格点的GeoJSON对象。

参数

  • bbox:Array。必选参数,表示生成点网格的区域边界,由四个坐标值组成的数组。形式为[west, south, east, north]。坐标值必须用十进制度数表示。
  • cellSize:Number。可选参数,表示点网格的单元格边长,单位为米。

返回值

  • GeoJSON。表示网格点的GeoJSON对象。

示例

var bbox = [-122.681949, 45.523062, -122.682249, 45.523462];
var cellSize = 50;

var pointGrid = turf.pointGrid(bbox, cellSize);

console.log(pointGrid);

返回值:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -122.68210653749204,
          45.52310815022336
        ]
      },
      "properties": {}
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -122.68198844401073,
          45.52310815022336
        ]
      },
      "properties": {}
    },
    ...
  ]
}

上述示例将在指定区域内生成一个单元格边长为50 米的网格状的点集,并将结果存储在pointGrid变量中。返回值为表示点网格的GeoJSON对象。