GEE使用多边形创建要素集

使用多边形创建要素集

主要功能

使用自定义的多边形来创建要素集

代码

// Create and render a feature collection from polygons.

// Construct a FeatureCollection from a list of features.
var fc = ee.FeatureCollection([
  // Create each feature with a geometry and properties.
  ee.Feature(
      ee.Geometry.Polygon({
        coords: [[-109.05, 41], [-109.05, 37], [-102.05, 37], [-102.05, 41]],
        geodesic: false, // The state boundaries are not geodesic.
        maxError: 1000 // Make the error margin large; we don't need accuracy.
      }), {name: 'Colorado', fill: 1}), // Pass properties as a dictionary.
  ee.Feature(
      ee.Geometry.Polygon({
        coords: [
          [-114.05, 37.0], [-109.05, 37.0], [-109.05, 41.0],
          [-111.05, 41.0], [-111.05, 42.0], [-114.05, 42.0]
        ],
        geodesic: false,
        maxError: 1000
      }), {name: 'Utah', fill: 2})
]);

// Fill, then outline the polygons into a blank image.
var image = ee.Image().toByte()
    .paint(fc, 'fill') // Get color from property named 'fill'
    .paint(fc, 3, 5); // Outline using color 3, width 5.

Map.addLayer(image, {
    palette: ['000000', 'FF0000', '00FF00', '0000FF'],
    max: 3,
    opacity: 0.5
});

Map.setCenter(-107, 41, 6);

步骤分析

  1. 使用拐点坐标和属性列表来创建若干个地理要素
  2. 使要素集包含创建的地理要素对象
  3. 将要素集输出为影像数据对象
  4. 添加要素对象显示图层
  5. 设置地图中心,缩放等级

主要方法

  1. ee.FeatureCollection()
    FeatureCollections can be constructed from the following arguments:
  • A string: assumed to be the name of a collection.
  • A single geometry.
  • A single feature.
  • A list of features.
  • A computed object: reinterpreted as a collection.
    Arguments:
    args (ComputedObject|Feature|FeatureCollection|Geometry|List|Number|String):
    The constructor arguments.
    column (String, optional):
    The name of the geometry column to use. Only useful with constructor type 1.
    Returns: FeatureCollection

    综合前文,一个FeatureCollection可以只包含一个地理要素,也可以包含多个地理要素。

    1. ee.Geometry.Polygon()
      Constructs an ee.Geometry describing a polygon.
      For convenience, varargs may be used when all arguments are numbers. This allows creating geodesic EPSG:4326 Polygons with a single LinearRing given an even number of arguments, e.g. ee.Geometry.Polygon(aLng, aLat, bLng, bLat, ..., aLng, aLat).
      Arguments:
      coords (List|List>>|List): A list of rings defining the boundaries of the polygon. May be a list of coordinates in the GeoJSON 'Polygon' format, a list of ee.Geometry describing a LinearRing, or a list of number defining a single polygon boundary.
      proj (Projection, optional): The projection of this geometry. The default is the projection of the inputs, where Numbers are assumed to be EPSG:4326.
      geodesic (Boolean, optional): If false, edges are straight in the projection. If true, edges are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers.
      maxError (ErrorMargin, optional): Max error when input geometry must be reprojected to an explicitly requested result projection or geodesic state.
      evenOdd (Boolean, optional): If true, polygon interiors will be determined by the even/odd rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left- inside rule, where interiors are on the left side of the shell's edges when walking the vertices in the given order. If unspecified, defaults to true.
      Returns: Geometry.Polygon

    创建多边形的地理要素,默认使用ESPG:4326地理坐标系。
    输入参数:地理坐标(一系列点),投影信息,geodesic(布尔值,控制地理要素是否贴合投影坐标系),容差,everOdd(布尔值,控制复杂多边形构建)

    你可能感兴趣的:(GEE使用多边形创建要素集)