美文网首页GEE案例
GEE中心枢纽灌溉检测

GEE中心枢纽灌溉检测

作者: 赤豆冰棍 | 来源:发表于2019-01-03 22:12 被阅读0次

    中心枢纽灌溉系统检测

    Center-pivot Irrigation,翻译为中心枢纽灌溉,是一种以圆心为供水点,使用灌溉支架绕中心旋转实现大面积灌溉的农业设施。因此,使用此类设备的农田一般呈圆形,聚集分布。

    主要功能

    代码

    // Center-pivot Irrigation Detector.
    //
    // Finds circles that are 500m in radius.
    Map.setCenter(-106.06, 37.71, 12);
    
    // A nice NDVI palette.
    var palette = [
      'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
      '74A901', '66A000', '529400', '3E8601', '207401', '056201',
      '004C00', '023B01', '012E01', '011D01', '011301'];
    
    // Just display the image with the palette.
    var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_034034_20170608');
    var ndvi = image.normalizedDifference(['B5','B4']);
    
    Map.addLayer(ndvi, {min: 0, max: 1, palette: palette}, 'Landsat NDVI');
    
    // Find the difference between convolution with circles and squares.
    // This difference, in theory, will be strongest at the center of
    // circles in the image. This region is filled with circular farms
    // with radii on the order of 500m.
    var farmSize = 500;  // Radius of a farm, in meters.
    var circleKernel = ee.Kernel.circle(farmSize, 'meters');
    var squareKernel = ee.Kernel.square(farmSize, 'meters');
    var circles = ndvi.convolve(circleKernel);
    var squares = ndvi.convolve(squareKernel);
    var diff = circles.subtract(squares);
    
    // Scale by 100 and find the best fitting pixel in each neighborhood.
    var diff = diff.abs().multiply(100).toByte();
    var max = diff.focal_max({radius: farmSize * 1.8, units: 'meters'});
    // If a pixel isn't the local max, set it to 0.
    var local = diff.where(diff.neq(max), 0);
    var thresh = local.gt(2);
    
    // Here, we highlight the maximum differences as "Kernel Peaks"
    // and draw them in red.
    var peaks = thresh.focal_max({kernel: circleKernel});
    Map.addLayer(peaks.updateMask(peaks), {palette: 'FF3737'}, 'Kernel Peaks');
    
    // Detect the edges of the features.  Discard the edges with lower intensity.
    var canny = ee.Algorithms.CannyEdgeDetector(ndvi, 0);
    canny = canny.gt(0.3);
    
    // Create a "ring" kernel from two circular kernels.
    var inner = ee.Kernel.circle(farmSize - 20, 'meters', false, -1);
    var outer = ee.Kernel.circle(farmSize + 20, 'meters', false, 1);
    var ring = outer.add(inner, true);
    
    // Highlight the places where the feature edges best match the circle kernel.
    var centers = canny.convolve(ring).gt(0.5).focal_max({kernel: circleKernel});
    Map.addLayer(centers.updateMask(centers), {palette: '4285FF'}, 'Ring centers');
    

    步骤分析

    1. 设置地图显示中心,缩放等级,定义一个色板
    2. 创建ee对象,获取LC08数据,使用特定波段,计算归一化植被指数(NDVI)
    3. 添加NDVI图层,使用定义的色板显示,名称为Landsat NDVI
    4. 定义农田半径500
    5. 定义核心,圆形,正方形,半径,边长都是500
    6. 分别使用两种核心,对NDVI结果进行卷积运算
    7. 从圆核心卷积结果中除去正方形核心卷积结果
    8. ...

    流程图

    GEE喷灌检测.png

    主要方法

    1. ee.Image.subtract()
      Subtracts the second value from the first for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is the union of the input types.
      Arguments:
      this:image1 (Image):
      The image from which the left operand bands are taken.
      image2 (Image):
      The image from which the right operand bands are taken.
      Returns: Image

    从第一个输入的影像中减去第一个影像中的对应波段数据,如果影像1或2只有一个波段,则被用于另一个影像的所有波段。如果有相同的波段数,但是不同名,则按照波段顺序来执行。
    输入参数:
    输入影像对象1
    输入影像对象2

    1. ee.Image.toByte()
      Casts the input value to an unsigned 8-bit integer.
      Arguments:
      this:value (Image):
      The image to which the operation is applied.
      Returns: Image

    投影一个输入影像为无符号八位整型数据。

    1. ee.Image.where()
      Performs conditional replacement of values.
      For each pixel in each band of 'input', if the corresponding pixel in 'test' is nonzero, output the corresponding pixel in value, otherwise output the input pixel.
      If at a given pixel, either test or value is masked, the input value is used. If the input is masked, nothing is done.
      The output bands have the same names as the input bands. The output type of each band is the larger of the input and value types. The output image retains the metadata and footprint of the input image.
      Arguments:
      this:input (Image):
      The input image.
      test (Image):
      The test image. The pixels of this image determines which of the input pixels is returned. If this is a single band, it is used for all bands in the input image. This may not be an array image.
      value (Image):
      The output value to use where test is not zero. If this is a single band, it is used for all bands in the input image.
      Returns: Image

    对影像执行条件替换,对于输入影像的每一个像元,如果影像非零,则替换为参考值,如果为零,则输出原始值。
    输入参数:
    输入影像,
    test(参考影像),该影像的像元值决定返回何值
    value,参考值

    1. ee.Image.neq(); ee.Image.gt();ee.Image.gte()
      Returns 1 if the first value is not equal to the second for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is boolean.
      Arguments:
      this:image1 (Image):
      The image from which the left operand bands are taken.
      image2 (Image):
      The image from which the right operand bands are taken.
      Returns: Image

    返回输入影像与参考影像不同部分,大于部分,大于等于部分。输出结果为布尔型。
    输入参数:输入影像,参考影像

    1. ee.Kernel.circle()
      Generates a circle-shaped boolean kernel.
      Arguments:
      radius (Float): The radius of the kernel to generate.
      units (String, default: "pixels"): The system of measurement for the kernel ('pixels' or 'meters'). If the kernel is specified in meters, it will resize when the zoom-level is changed.
      normalize (Boolean, default: true): Normalize the kernel values to sum to 1.
      magnitude (Float, default: 1): Scale each value by this amount.
      Returns: Kernel

    生成一个圆形布尔核心
    输入参数:
    半径(浮点型),单位(默认为像素,也可以指定为米),归一化(布尔值,默认为真,即保证核的所有值总和为1),放大(默认为1,即可以设置一个统一系数)

    1. ee.Image.convolve()
      Convolves each band of an image with the given kernel.
      Arguments:
      this:image (Image): The image to convolve.
      kernel (Kernel): The kernel to convolve with.
      Returns: Image

    对输入影像对象的每一个波段执行卷积。
    输入参数:输入影像对象,卷积核

    相关文章

      网友评论

        本文标题:GEE中心枢纽灌溉检测

        本文链接:https://www.haomeiwen.com/subject/ptbfrqtx.html