GEE中心枢纽灌溉检测

中心枢纽灌溉系统检测

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

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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,029评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,395评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,570评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,535评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,650评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,850评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,006评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,747评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,207评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,536评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,683评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,342评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,964评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,772评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,004评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,401评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,566评论 2 349

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,312评论 0 10
  • 走累了, 就停下来,歇一歇。 让疲惫的身心,学会放松。 看着路人的笑脸, 看着老人慈祥的面庞, 看着恋人间的小甜蜜...
    cbb625061962阅读 236评论 0 2
  • 人生如逆水行舟,逆风飞翔,不进则退,海天一色,如何只进不退?唯,迂回前行,盘旋上升! 所有大山之上的路,都是盘山公...
    纵情嬉戏天地间阅读 306评论 0 1
  • 文|吴少如 杏鲍菇是开发栽培成功的集食用、药用、食疗于一体的珍稀食用菌新品种。菇体具有杏仁香味,肉质肥厚,口感鲜嫩...
    吴少如阅读 659评论 1 1