【GEE】Google Earth Engine(GEE)注册详细教程&无需教育邮箱-CSDN博客
数据下载代码
// Map the function over 3 months of data and take the median.
// Load Landsat-8 surface reflectance data.var landsat8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2").filterBounds(table).filterDate('2023-10-1','2024-1-15')// Pre-filter to get less cloudy granules..filter(ee.Filter.lte('CLOUD_COVER',10)).median().clip(table);print(landsat8);// visualize the datasets
var rgbVis = {min: 8400,max: 15000,gamma:1.5,bands: ['SR_B4', 'SR_B3', 'SR_B2'],
};Map.addLayer(landsat8,rgbVis,'landsat8');
var imgselect = landsat8.select('SR_B2','SR_B3','SR_B4','SR_B5', 'ST_B10');
//Export image to google drive and then downloadExport.image.toDrive({image:imgselect,description:'s4',scale:30,region:table,folder:"result",crs: "EPSG:4326",maxPixels: 1e13
});
摄影时间代码
Map.setCenter(113.07676218077592, 34.04984227876722, 6)
//选泽河南省一个点为地图显示中心
var bounds = Map.getBounds(true)
var scale = Map.getScale()
var images = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
.select([5,4,2])
.filterBounds(table)
.filterDate('2023-12-1','2024-1-1')
var text = require('users/gena/packages:text')
// 呈现带注释的图像
function annotate(images) {return images.map(function(i) {var geom = i.select(0).geometry()var center = ee.List(geom.centroid().coordinates())// 在图像周围添加边缘 var edge = ee.Image(0).toByte().paint(geom, 1, 2)edge = edge.mask(edge).visualize({palette:['cccc00'], opacity: 0.9})// 定义文本属性var props = { textColor: '000000', outlineColor: 'ffffff', outlineWidth: 2.5, outlineOpacity: 0.6}// 绘制拍摄时间及云量var pos = translate(center, 0.7, -0.4)var s = ee.String(i.get('DATE_ACQUIRED'))var textDate = text.draw(s, pos, scale, props)pos = translate(center, 0.7, -0.1)s = ee.String(i.get('SCENE_CENTER_TIME')).slice(0, 5)var textTime = text.draw(s, pos, scale, props)return ee.ImageCollection([edge, textDate, textTime]).mosaic() // merge results})
}// 转换dx, dy点的坐标
function translate(pt, dx, dy) {var x1 = ee.Number(pt.get(0)).subtract(dx)var y1 = ee.Number(pt.get(1)).subtract(dy)return ee.Geometry.Point(ee.List([x1, y1]))
}
//在地图上显示
Map.addLayer(images, {}, '图像')
Map.addLayer(annotate(images), {}, '文本')
2023.10-15-10.31