使用 SENTINEL 1 和 2 进行土地覆盖分类

1.前言

         Sentinel-1 和 Sentinel-2 卫星都以非常高的空间分辨率和良好的时间分辨率对地球进行测量。 这些数据对于绘制土地利用和土地利用变化图非常有用。 本教程展示了如何使用简单的算法来识别水、茂密植被、定居点和稻田的区域。

2.代码实现

(1)导入 Sentinel-1 和 Sentinel-2 ImageCollection

 (2)定义地理和时间域

// Define period
var startdate = ee.Date.fromYMD(2014,1,1);
var enddate = ee.Date.fromYMD(2016,12,1);
 
// Define geograpic domain
var Ca = ee.FeatureCollection('ft:1T7GmJ0tJCu4QwclY5qiG9EGBFgNhhNjttq8F7gQm');
Map.centerObject(Ca,8);

(3) 过滤数据

// filter s2 data</pre>
var Sentinel2 = s2.filterBounds(Ca)
.filterDate(startdate, enddate)
.filterBounds(Ca);
 
// filter s1 data
var Sentinel1 =  ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(Ca)
.filterDate(startdate, enddate)
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.select('VV');

(4) 从 Sentinel-2 移除云层

// cloud function to remove clouds
var cloudfunction_ST2 = function(image){
  //use add the cloud likelihood band to the image
  var quality = image.select("QA60").unmask();
  //get pixels above the threshold
  var cloud01 = quality.gt(0);
  //create a mask from high likelihood pixels
  var cloudmask = image.mask().and(cloud01.not());
  //mask those pixels from the image
  return image.updateMask(cloudmask);
};
 
// remove the clouds
var ST2_nocloud = Sentinel2.map(cloudfunction_ST2);

(5) 从 Sentinel-2 的中值计算 NDBI、NDVI 和 NDWI

// take the median
var st2median = ST2_nocloud.median();
 
// the normalized difference bare index
var ndbi = st2median.normalizedDifference(['B12', 'B8']);
 
// the normalized difference vegetation index
var ndvi = st2median.normalizedDifference(['B8', 'B4']);
 
// the normalize difference water index
var ndwi = st2median.normalizedDifference(['B3', 'B8']);

 (6)设置索引的阈值

// define thresholds
var bareThreshold = -0.32
var vegetationThreshold = 0.65
var waterThreshold = 0.2

 (7)将不同的图层添加到画布

// show the urban area
var ndbi_th = ndbi.gt(bareThreshold)
var myndbi = ndbi_th.updateMask(ndbi_th).clip(Ca)
var ndbi_viz = {palette:"111101"};
Map.addLayer(myndbi, ndbi_viz, 'Urban');
 
// show the water areas
var ndwi_th = ndwi.gt(waterThreshold)
var myndwi = ndwi_th.updateMask(ndwi_th).clip(Ca)
var ndwi_viz = {palette:"24069b"};
Map.addLayer(myndwi, ndwi_viz, 'Water');
 
// show the forests
var ndvi_th = ndvi.gt(vegetationThreshold)
var myndvi = ndvi_th.updateMask(ndvi_th).clip(Ca)
var ndvi_viz = {palette:"006b0c"};
Map.addLayer(myndvi, ndvi_viz, 'Vegetation');

 (8)在 sentinel-1 图像上使用 reducer 函数比较干湿条件

// create a map of the wet and dry conditions from sentinel-1
var wet = Sentinel1.reduce(ee.Reducer.percentile([10]))
var dry = Sentinel1.reduce(ee.Reducer.percentile([90]))

(9) 识别在雨季被淹没而在旱季干燥的稻田

// calculate the difference between wet and dry conditions
var paddies = wet.subtract(dry)

(10) 山可以被识别为稻田,所以我们去除所有大于 2 度的坡度

// remove the mountains from the data
var hydrosheds = ee.Image('WWF/HydroSHEDS/03VFDEM');
var terrain = ee.Algorithms.Terrain(hydrosheds);
var slope = terrain.select('slope');
 
// remove all slopes greater then 2 degrees
paddies = paddies.updateMask(slope.lt(2));

(11) 还根据 -8 的阈值将稻田添加到地图中

// set the paddy threshold
var paddies_th = -8;
 
// select areas smaller than the threshold
var paddies_th = paddies.lt(paddies_th);
 
// mask the areas that are not rice paddies
var mypaddies = paddies_th.updateMask(paddies_th).clip(Ca)
 
var paddies_viz = {palette:"c2c64d"};
Map.addLayer(mypaddies, paddies_viz, 'Rice');

3.实现效果 

使用 SENTINEL 1 和 2 进行土地覆盖分类_第1张图片

你可能感兴趣的:(GEE,sentinel,GEE)