文章内容仅用于自己知识学习和分享,如有侵权,还请联系并删除 :)
1. 目的:提取给定站点(经纬度)的aridity index值
2. 数据来源:Zomer R J, Xu J, Trabucco A. Version 3 of the global aridity index and potential evapotranspiration database[J]. Scientific Data, 2022, 9(1): 409. link
3. 数据简介


4. 代码
-
GEE: link
-
GEE提取给定经纬度AI值
我当时是将link 中的文件下载下来,传到GEE再提取,后来发现它直接提供了aridity index image的链接,可以跳过这一步。
// 以Global-AI_ET0_v3_annual/ai_v3_yr.tif为例
// step1: 将本地的"ai_v3_yr.tif"和经纬度shapefile文件"site_LATLON"分别上传到GEE
// step2: GEE code
/*---------------------------------*/
// 1. 导入数据
/*---------------------------------*/
var aridity_index = ee.Image("users/xxx/ai_v3_yr") //aridity index文件
var table = ee.FeatureCollection("projects/xxx/assets/site_LATLON"); //经纬度文件
var fluxnetsite = ee.FeatureCollection(table3);
//print('fluxnetsite',fluxnet2015site);
/*---------------------------------*/
// 2. Display AI map
/*---------------------------------*/
//==================
// 2.1 显示底图
//==================
//(1) Import palette
var palettes = require('users/gena/packages:palettes')
/*
(2) Convert back by multiplying by 10,000 [The Aridity Index values reported within the Global Aridity Index_ET0 geodataset
have been multiplied by a factor of 10,000 to derive and distribute the data as integers (with 4 decimal accuracy).
This multiplier has been used to increase the precision of the variable values without using decimals.]
*/
var image = ee.Image(aridity_index.multiply(0.0001))
// (3) Define an SLD style of discrete intervals to apply to the image.
// Blue: light to deep,Hyper Arid to Humid
var sld_intervals =
'<RasterSymbolizer>' +
'<ColorMap type="intervals" extended="false" >' +
'<ColorMapEntry color="#D2E1E6" quantity="0.03" label="0-0.03"/>' + //Oyster Boy: Hyper Arid
'<ColorMapEntry color="#C1E3ED" quantity="0.21" label="0.03-0.2" />' + //Onahau: Arid
'<ColorMapEntry color="#AAC9DD" quantity="0.51" label="0.2-0.51" />' + //Light steel blue:Semi-Arid
'<ColorMapEntry color="#78AED3" quantity="0.65" label="0.5-0.65" />' + //Swagull: Dry sub-humid
'<ColorMapEntry color="#4F77AA" quantity="2.5" label=">0.66" />' + //San Marino: Humid
'</ColorMap>' +
'</RasterSymbolizer>';
Map.addLayer(image.sldStyle(sld_intervals),{},'Aridity index')
Map.addLayer(image,{'min':0,'max':2.5,palette: palettes.cmocean.Haline[7]},'Aridity Index',false)
//==================
// 2.2 Add lengend
//==================
// (1)set position of panel
var legend = ui.Panel({
style: {
position: 'bottom-right',//'bottom-left',
padding: '8px 15px'
}
});
// (2) Create legend title
var legendTitle = ui.Label({
value: 'Aridity Index',
style: {
fontWeight: 'bold',
fontSize: '18px',
margin: '0 0 4px 0',
padding: '0'
}
});
// (3) Add the title to the panel
legend.add(legendTitle);
// (4) Creates and styles 1 row of the legend.
var makeRow = function(color, name) {
// Create the label that is actually the colored box.
var colorBox = ui.Label({
style: {
backgroundColor: '#' + color,
// Use padding to give the box height and width.
padding: '8px',
margin: '0 0 4px 0'
}
});
// Create the label filled with the description text.
var description = ui.Label({
value: name,
style: {margin: '0 0 4px 6px'}
});
// return the panel
return ui.Panel({
widgets: [colorBox, description],
layout: ui.Panel.Layout.Flow('horizontal')
});
};
// (5) Palette with the colors
var palette =["D2E1E6","C1E3ED","AAC9DD","78AED3","4F77AA"];
// (6) name of the legend
var names = ['Hyper Arid(<0.03)','Arid(0.03-0.2)','Semi-Arid(0.2-0.5)','Dry sub-humid(0.5-0.65)','Humid(>0.65)'];
// (7) Add color and and names
for (var i = 0; i < 5; i++) {
legend.add(makeRow(palette[i], names[i]));
}
// (8) add legend to map (alternatively you can also print the legend to the console)
Map.add(legend);
/*---------------------------------*/
// 3. Display site distribution
/*---------------------------------*/
// Paint FeatureCollection to an image using collection-wide style arguments.
var fcVis = fluxnetsite.style({
color: 'black',
width: 0.5,
fillColor: 'orange',//'#67b932', // with alpha set for partial transparency
//lineType: 'dotted',
pointSize: 5,
pointShape: 'circle'
});
Map.addLayer(fcVis, null, 'FLUXNET');
/*---------------------------------
4. 导出数据到 csv文件
--------------------------------*/
var extractData =image.reduceRegions({
collection: fluxnetsite,
crs: ee.Projection('EPSG:4326'),
scale:30,
reducer: ee.Reducer.mean()});
Export.table.toDrive({
collection: extractData,
description: 'Aridity_index_site.csv',
folder: 'Aridity_index/',
fileFormat: 'CSV'
});
1240

被折叠的 条评论
为什么被折叠?



