GEE 代码学习day1

第一章-像素

var first_image = ee.Image(  'LANDSAT/LT05/C02/T1_L2/LT05_118038_20000606');
print(first_image);
Map.addLayer( first_image, // dataset to display
               {  bands: ['SR_B1'], // band to display 
                  min: 8000, // display range
                  max: 17000 },
                  'Layer 1' // name to show in Layer Manager );
Map.addLayer( first_image, 
            {  
              bands: ['SR_B2'], 
              min: 8000, 
              max: 17000 }, 
              'Layer 2', 
               0, // shown
               1 // opacity );  
Map.addLayer( first_image, 
             {  bands: ['SR_B3'], 
               min: 8000, 
               max: 17000 }, 
               'Layer 3', 
                 1, // shown 
                 0 // opacity 
                  );
Map.addLayer( first_image, 
              { 
                bands: ['SR_B3', 'SR_B2', 'SR_B1'],
                min: 8000, 
                 max: 17000 }, 
                'Natural Color');
Map.addLayer( first_image, 
              {  
                bands: ['SR_B4', 'SR_B3', 'SR_B2'], 
                min: 8000, 
                max: 17000 }, 
                'False Color');
Map.addLayer( first_image, 
              {  
                 bands: ['SR_B5', 'SR_B4', 'SR_B2'], 
                 min: 8000, 
                 max: 17000 }, 
              'Short wave false color');
var lights93 = ee.Image('NOAA/DMSP- OLS/NIGHTTIME_LIGHTS/F101993');  
print('Nighttime lights', lights93);  
Map.addLayer( lights93, {  bands: ['stable_lights'], min: 0, max: 63 }, 'Lights');
var lights03 = ee.Image('NOAA/DMSP- OLS/NIGHTTIME_LIGHTS/F152003')  .select('stable_lights').rename('2003');  
var lights13 = ee.Image('NOAA/DMSP- OLS/NIGHTTIME_LIGHTS/F182013') .select('stable_lights').rename('2013');  
var changeImage = lights13.addBands(lights03).addBands(lights93.select('stable_lights').rename('1993'));  print('change image', changeImage); 
 Map.addLayer( changeImage, {  min: 0, max: 63 }, 'Change composite');

第二章-不同类型的数据集

1、NASA 和美国地质勘探局 (USGS) 的 Landsat 

/ 
// View an Image Collection
/  
// Import the Landsat 8 Raw Collection. 
var landsat8 = ee.ImageCollection('LANDSAT/LC08/C02/T1');  
// Print the size of the Landsat 8 dataset. 
print('The size of the Landsat 8 image collection is:', landsat8 .size());  
// Try to print the image collection. 
// WARNING! Running the print code immediately below produces an error because 
// the Console can not print more than 5000 elements. 
print(landsat8);  
// Add the Landsat 8 dataset to the map as a mosaic. The collection is 
// already chronologically sorted, so the most recent pixel is displayed.
Map.addLayer(landsat8, 
            {  bands: ['B4', 'B3', 'B2'],
               min: 5000, 
               max: 15000 },
             'Landsat 8 Image Collection');
// Filter an Image Collection
/  
// Filter the collection by date. 
var landsatWinter = landsat8.filterDate('2020-12-01',  '2021-03-01');  Map.addLayer(landsatWinter, 
            {  
            bands: ['B4', 'B3', 'B2'], 
            min: 5000, 
            max: 15000 }, 
            'Winter Landsat 8');  
print('The size of the Winter Landsat 8 image collection is:', landsatWinter.size());
// Create an Earth Engine Point object. 
var pointMN = ee.Geometry.Point([-93.79, 45.05]);  
// Filter the collection by location using the point. 
var landsatMN = landsatWinter.filterBounds(pointMN);  
Map.addLayer(landsatMN, 
             {  bands: ['B4', 'B3', 'B2'], 
                min: 5000, 
                max: 15000 }, 
               'MN Landsat 8'); 
// Add the point to the map to see where it is. 
Map.addLayer(pointMN, {}, 'Point MN');  
print('The size of the Minneapolis Winter Landsat 8 image collection is:',landsatMN.size());
// Select the first image in the filtered collection. 
var landsatFirst = landsatMN.first();  
// Display the first image in the filtered collection. 
Map.centerObject(landsatFirst, 7); 
Map.addLayer(landsatFirst, {  bands: ['B4', 'B3', 'B2'], min: 5000, max: 15000 }, 'First Landsat 8');

filterDate:which allows us to narrow down the date range of the ImageCollection.

filterBounds:is based on a location—for example, a point, polygon, or other geometry.

first: selects the first image in an ImageCollection.

Map.centerObject: center the map on the landsatFirst image with a zoom level of 7 (zoom levels go from 0 to 24).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值