当前位置:网站首页>GEE:(二)对影像进行重采样
GEE:(二)对影像进行重采样
2022-07-02 21:32:00 【BetterQ.】
在使用GEE对影像进行重采样时,主要用到.reproject(crs, crsTransform, scale)函数,下面对该函数的参数以及使用进行介绍。img.reproject(crs, crsTransform, scale)
this:image (Image):
需要重投影的影像
crs (Projection):
重投影时的坐标系
crsTransform (List, default: null):
The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with the scale option, and replaces any transform already on the projection.
scale (Float, default: null):
在重投影时可以对分辨率进行设置
这里将Sentinel-2影像重采样到100m作为例子,在GEE中实现代码如下:
//去云函数
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 geometry =
ee.Geometry.Polygon(
[[[17.86466765871711, 51.805755132803185],
[17.86466765871711, 48.51354071088587],
[24.85197234621711, 48.51354071088587],
[24.85197234621711, 51.805755132803185]]], null, false);
//导入哨兵2数据
var image = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2017-02-01', '2017-11-30')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))
.map(maskS2clouds)
.median()
.clip(geometry);
//输出未重投影时的坐标系以及分辨率
print('Proj and transform info of image:', image.projection().getInfo())
print('Pixel size in meters:', image.projection().nominalScale().getInfo())
//输出重投影后的坐标系以及分辨率,这里将分辨率设置为100m
var reprojected = image.reproject('EPSG:4326',null,100);
print('Proj and transform info after reprojection:', reprojected.projection());
print('Pixel size in meters:', reprojected.projection().nominalScale());
结果:
上述方法其实是对原始影像数据进行重投影,在重投影时将分辨率重新设置了,在官网还给了一种重采样的方法,使用的是.resample()函数,具体实现代码如下:
// 加载landsat影像
var landsat = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20160323');
// 设置展示参数
Map.setCenter(-122.37383, 37.6193, 15);
var visParams = {
bands: ['B4', 'B3', 'B2'], max: 0.3};
//一般最开始加载影像时默认使用的是最邻近像元插值
Map.addLayer(landsat, visParams, 'original image');
// 对其采用双三次曲线重新采样
var resampled = landsat.resample('bicubic');
// 展示重采样后的数据
Map.addLayer(resampled, visParams, 'resampled');
如果在实际当中,我们有10m和500m的数据,需要统一尺度,就需要对10m的影像进行下采样,可结合.reduceResolution和.reproject实现:
// Load a MODIS EVI image.
var modis = ee.Image(ee.ImageCollection('MODIS/006/MOD13A1').first())
.select('EVI');
// Display the EVI image near La Honda, California.
Map.setCenter(-122.3616, 37.5331, 12);
Map.addLayer(modis, {
min: 2000, max: 5000}, 'MODIS EVI 500 m');
// Get information about the MODIS projection.
var modisProjection = modis.projection();
print('MODIS projection:', modisProjection);
// Load and display forest cover data at 30 meters resolution.
var forest = ee.Image('UMD/hansen/global_forest_change_2015')
.select('treecover2000');
Map.addLayer(forest, {
max: 80}, 'forest cover 30 m');
// Get the forest cover data at MODIS scale and projection.
var forestMean = forest
// Force the next reprojection to aggregate instead of resampling.
.reduceResolution({
reducer: ee.Reducer.mean(),
maxPixels: 1024
})
// Request the data at the scale and projection of the MODIS image.
.reproject({
crs: modisProjection
});
// Display the aggregated, reprojected forest cover data.
Map.addLayer(forestMean, {
max: 80}, 'forest cover at MODIS scale 500 m');
边栏推荐
- AES encryption CBC mode pkcs7padding filling Base64 encoding key 32byte iv16byte
- Common routines of compressed packets in CTF
- Centos7 installation and configuration of redis database
- I drew a Gu ailing with characters!
- Accounting regulations and professional ethics [19]
- MySQL learning record (2)
- MySQL inserts Chinese data and reports an error. Set the default collation
- [shutter] shutter layout component (fractionallysizedbox component | stack layout component | positioned component)
- Physical layer cables and equipment
- Analysis of neural network
猜你喜欢

Basic IO interface technology - microcomputer Chapter 7 Notes

Report on investment development and strategic recommendations of China's vibration isolator market, 2022-2027

Redis distributed lock failure, I can't help but want to burst
![[shutter] shutter layout component (opacity component | clipprect component | padding component)](/img/6b/4304be6a4c5427dcfc927babacb4d7.jpg)
[shutter] shutter layout component (opacity component | clipprect component | padding component)

Browser - clean up the cache of JS in the page

Investment strategy analysis of China's electronic information manufacturing industry and forecast report on the demand outlook of the 14th five year plan 2022-2028 Edition
![[question brushing diary] classic questions of dynamic planning](/img/31/fcd8230f809d6178f11e7095c1ef94.jpg)
[question brushing diary] classic questions of dynamic planning

MySQL learning record (5)

Analysis of neural network

D4:非成对图像去雾,基于密度与深度分解的自增强方法(CVPR 2022)
随机推荐
Gbase8s database type
[dynamic planning] p1220: interval DP: turn off the street lights
Today, I met a Alipay and took out 35K. It's really sandpaper to wipe my ass. it's a show for me
Structured text language XML
Construction and maintenance of business websites [6]
How to prevent your jar from being decompiled?
Construction and maintenance of business website [1]
Construction and maintenance of business websites [7]
China's crude oil heater market trend report, technological innovation and market forecast
mysql
A river of spring water flows eastward
The web version of xshell supports FTP connection and SFTP connection
Cloud computing technology [1]
[shutter] the shutter plug-in is used in the shutter project (shutter plug-in management platform | search shutter plug-in | install shutter plug-in | use shutter plug-in)
Basic knowledge of tree and binary tree (detailed illustration)
Check the confession items of 6 yyds
~91 rotation
Go web programming practice (1) -- basic syntax of go language
Structure array, pointer and function and application cases
Common authority query instructions in Oracle