GEE面积过滤器

计算多边形面积属性用于过滤多边形对象

主要功能

找出美国所有面积小于3000平方千米的县

代码

// Computed area filter.
// Find US counties smaller than 3k square kilometers in area.

// Load counties from TIGER boundaries table
var counties = ee.FeatureCollection('TIGER/2016/Counties');

// Map a function over the counties to set the area of each.
var countiesWithArea = counties.map(function(f) {
  // Compute area in square meters.  Convert to hectares.
  var areaHa = f.area().divide(100 * 100);

  // A new property called 'area' will be set on each feature.
  return f.set({area: areaHa});
});

// Filter to get only smaller counties.
var smallCounties = countiesWithArea.filter(ee.Filter.lt('area', 3e5));

Map.addLayer(smallCounties, {color: '900000'});

Map.setCenter(-119.7, 38.26, 7);

步骤分析

  1. 使用已有的要素集筛选特定图层
  2. 计算县图层中所有要素的面积,返回指定单位面积结果
  3. 使用面积计算结果来过滤数据
  4. 添加筛选结果图层
  5. 设置地图中心,缩放等级

主要方法

  1. ee.Feature.area()
    Returns the area of the feature's default geometry. Area of points and line strings is 0, and the area of multi geometries is the sum of the areas of their componenets (intersecting areas are counted multiple times).
    Arguments:
    this:feature (Element):
    The feature from which the geometry is taken.
    maxError (ErrorMargin, default: null):
    The maximum amount of error tolerated when performing any necessary reprojection.
    proj (Projection, default: null):
    If specified, the result will be in the units of the coordinate system of this projection. Otherwise it will be in square meters.
    Returns: Float

返回要素特征的面积(默认投影)。点,线要素的面积为0,复杂多边形返回多个多边形面积总和,重叠部分多次计算。
输入参数:要素、容差、投影坐标系。
返回值:浮点型面积值。

  1. ee.Feature.set()
    Overrides one or more metadata properties of an Element.
    Returns the element with the specified properties overridden.
    Arguments:
    this:element (Element):
    The Element instance.
    var_args (VarArgs<Object>):
    Either a dictionary of properties, or a vararg sequence of properties, e.g. key1, value1, key2, value2, ...
    Returns: Element

设置或者重写一个或多个要素特征。
输入参数:要素,属性赋值语句。赋值语句可以是字典,列表均可。
返回值:设定了新参数,或者重写旧参数的要素。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,504评论 0 13
  • 这天我正在看电视,电视里正在放一部中国片。就是《熊出没》,那里面正在讲一个故事讲的是熊二,被雷劈到了,拥有了读心术...
    董吴昊阅读 482评论 0 2
  • 没有了敌人,没有了对手,没有了朋友,只有自己在上,一个,孤另另,凄凉,寂寞,便反而感到了胜利的悲哀。 说:我想和你...
    更欣阅读 433评论 0 17
  • 有些事从理性的层面是好事当真正经历时却是如此痛苦每天都在努力的挣扎只为能够突破自我内心又是拒绝的这种痛苦犹如万箭穿...
    承谦阅读 164评论 0 0
  • 第三讲:春秋时期的舞台需求(1) 孔子生活的时代,离现在已经很久远了。2500多年前。那个时代按历史划分属于中国的...
    散翁阅读 1,053评论 2 1