AI智能
改变未来

Google Earth Engine(GEE)对Sentinel-2数据进行批量读取并以交互模式依次显示

Google Earth Engine (GEE) 是由谷歌公司开发的众多应用之一。借助谷歌公司超强的服务器运算能力以及与NASA的合作关系,GEE平台将Landsat/Sentinel等可以公开获取的遥感图像数据存储在谷歌的磁盘阵列中,使得GEE用户可以方便的提取、调用和分析海量的遥感大数据资源。

 

本文基于GEE平台,实现对Sentinel-2数据进行批量读取并以交互模式依次显示,示例地点为九寨沟景区附近。代码如下:

(JS)

[code]var S2 = ee.ImageCollection(\"COPERNICUS/S2\");var roi = China.filterBounds(point).geometry();//var l8 = ee.ImageCollection(\"LANDSAT/LC08/C01/T1_RT_TOA\");var rawCol = S2.filterDate(\"2017-1-1\", \"2019-12-31\").filterBounds(roi);//method 3var rawLayer = null;var computedIds = rawCol.reduceColumns(ee.Reducer.toList(), [\'system:index\']).get(\'list\');computedIds.evaluate(function(ids) {print(\"computedIds \", ids);var total = ids.length;var showTitle = ui.Label(\"\", {fontWeight: \'bold\'});var curIndex = 0;var bPlus = ui.Button(\"+\", function() {curIndex += 1;if (curIndex >= total) {curIndex = 0;}showTitle.setValue(ids[curIndex]);showSelectRawImage(ids[curIndex]);});var bReduce = ui.Button(\"-\", function() {curIndex -= 1;if (curIndex < 0) {curIndex = total - 1;}showTitle.setValue(ids[curIndex]);showSelectRawImage(ids[curIndex]);});showTitle.setValue(ids[curIndex]);showSelectRawImage(ids[curIndex]);var main = ui.Panel({widgets: [ui.Label(\'click \"+\" or \"-\" to move time window\', {fontWeight: \'bold\'}),bPlus, bReduce,ui.Label(\"select date: \", {fontWeight: \'bold\'}),showTitle],style: {width: \'200px\', padding: \'8px\'}});ui.root.insert(0, main);});function showSelectRawImage(key) {if (rawLayer !== null) {Map.remove(rawLayer);}print(\"show raw image id is: \" + key);var image = ee.Image(rawCol.filter(ee.Filter.eq(\"system:index\", key)).first().divide(10000));rawLayer = Map.addLayer(image, {bands:[\"B4\", \"B3\", \"B2\"], min:0, max:0.3}, key);}Map.centerObject(roi);

注:①使用前,需要import我国的行政区划文件,其次需要选取例如湖南省长沙市境内的一点(point),最后import导入S2图                 像。

       ②关于我国行政区划文件,分享百度网盘:链接:https://pan.baidu.com/s/1vrT5AmRTX8KmMMbpGtTAcg 
                                                                           提取码:o5vt

       ③使用左侧交互界面的“+”,“-”进行图像切换,图像名显示于控制台

效果:

参考文章:https://www.zhihu.com/people/li-shi-wei-36/posts?page=4

感谢知乎用户:无形的风对于GEE使用的教程!

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Google Earth Engine(GEE)对Sentinel-2数据进行批量读取并以交互模式依次显示