Python----global和nolocal关键字的用法(python global nonlocal)
732
2022-08-23
Google Earth Engine(GEE)基于哨兵数据计算植被覆盖度—以宁夏为例(google play服务)
今天来分享一下如何在GEE中基于哨兵二号数据计算植被覆盖度,并分级制图。
以宁夏回族自治区为研究区
代码如下:
var roi = ee.FeatureCollection("users/lilei655123/Ningxia");Map.centerObject(roi,7)//boundaryvar styling = {color:"red",fillColor:"00000000"};Map.addLayer(roi.style(styling),{},"geometry")function maskS2clouds(image) { var qa = image.select('QA60'); // Bits 10 and 11 are clouds and cirrus, respectively. var cloudBitMask = 1 << 10; var cirrusBitMask = 1 << 11; // Both flags should be set to zero, indicating clear conditions. var mask = qa.bitwiseAnd(cloudBitMask).eq(0) .and(qa.bitwiseAnd(cirrusBitMask).eq(0)); return image.updateMask(mask).divide(10000);}var S2 = ee.ImageCollection('COPERNICUS/S2_SR') .filterDate('2021-07-01', '2021-09-30') .filterBounds(roi) // Pre-filter to get less cloudy granules. .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',10)) .map(maskS2clouds) .median();//ndvi var NDVI1 = S2.expression('(NIR-R)/(NIR+R)',{ 'R': S2.select(['B4']), 'NIR': S2.select(['B8']),}) var imgFVC = ((NDVI1.subtract(ee.Image(0.05))).divide((ee.Image(0.95)).subtract(ee.Image(0.05)))).float(); var FVC=((imgFVC.lt(0)).multiply(0)) .add(((imgFVC.gt(0)).and(imgFVC.lte(1))).multiply(imgFVC)) .add((imgFVC.gt(1)).multiply(1))var FVC_Class=FVC.where(FVC.lt(0.2),1) .where(((FVC.gte(0.2)).and(FVC.lt(0.4))),2) .where(((FVC.gte(0.4)).and(FVC.lt(0.6))),3) .where(((FVC.gte(0.6)).and(FVC.lt(0.8))),4) .where(FVC.gt(0.8),5)Map.addLayer(FVC_Class.clip(roi),{min:1,max:5,palette:['DCDCDC','FFEBCD','99B718','529400','011301']},'FVC_Class')var visualization = { min: 0.0, max: 0.3, bands: ['B4', 'B3', 'B2'],};Map.addLayer(S2.clip(roi), visualization, 'RGB');
显示结果如下:
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~