编程 | 22秒带你看完密云水库2015年-2021年水体变化
2021/9/18 9:06:10
本文主要是介绍编程 | 22秒带你看完密云水库2015年-2021年水体变化,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.背景介绍
在北京的朋友可能感觉到了,北京貌似整个夏天一直在下雨。偶然间我看到这样的一个新闻:
这就激起了我的兴趣了,我想用遥感看看这几年密云水库是如何变化的。
2.工具与数据
工具:Google Earth Engine
数据:Sentinel-2 MSI Level 1C
时间:2015年9月—2021年9月
3.研究方法
4.方法实现
数据筛选:
//时间 var startDate = ee.Date('2015-9-1'); var endDate = ee.Date('2021-9-30'); //筛选 var sentinelcollection = SENTINEL .filterDate(startDate, endDate)//时间过滤 .filterBounds(roi)//位置过滤 .filterMetadata("MGRS_TILE", "equals", "50TMK")//条带号过滤 .filter(ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE',5))//云量过滤
格式转换
//待筛选的波段 var bands = ['B3','B4','B8'] //数据格式转换 sentinelcollection = sentinelcollection.map(function(image){ //影像像素深度转为Unit8 image=image.add(32768).divide(65536).multiply(255).uint8() //波段重命名 image=image.select(['B3', 'B4', 'B8'],['B8', 'B4', 'B3']) return image.select(bands) })
影像拉伸
//影像拉伸 var sentinelcollection2 = sentinelcollection.map(function(image){ image=(image.subtract(120)).divide(40).multiply(255) return image.uint8() })
导出视频
// 导出视频 Export.video.toDrive({ collection: sentinelcollection2, description: 'water', dimensions: 720, framesPerSecond: 3,//帧率 region: roi, })
完整代码:
//批量处理函数 Map.centerObject(roi, 11) //时间 var startDate = ee.Date('2015-9-1'); var endDate = ee.Date('2021-9-30'); //筛选 var sentinelcollection = SENTINEL .filterDate(startDate, endDate)//时间过滤 .filterBounds(roi)//位置过滤 .filterMetadata("MGRS_TILE", "equals", "50TMK")//条带号过滤 .filter(ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE',5))//云量过滤 //待筛选的波段 var bands = ['B3','B4','B8'] //数据格式转换 sentinelcollection = sentinelcollection.map(function(image){ //影像像素深度转为Unit8 image=image.add(32768).divide(65536).multiply(255).uint8() //波段重命名 image=image.select(['B3', 'B4', 'B8'],['B8', 'B4', 'B3']) return image.select(bands) }) //影像拉伸 var sentinelcollection2 = sentinelcollection.map(function(image){ image=(image.subtract(120)).divide(40).multiply(255) return image.uint8() }) Map.addLayer(sentinelcollection.first()) Map.addLayer(sentinelcollection2.first()) // 导出视频 Export.video.toDrive({ collection: sentinelcollection2, description: 'water', dimensions: 720, framesPerSecond: 3,//帧率 region: roi, })
链接:
完整代码链接:
https://code.earthengine.google.com/5993bea8a031d03ad353d38a36c7dc07
打开链接,直接在Google earth中运行。如果你需要换成其他区域,该代码只需要在筛选中去掉“条带号”的指定语句。
5.图像对比图
2020年9月9日密云水库的水体分布图
2021年9月9日密云水库的水体分布图
这篇关于编程 | 22秒带你看完密云水库2015年-2021年水体变化的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)