—— 要投稿,上万维,轻松学术交流

严正声明

本站非期刊官网,非中介代理,
不向作者收取任何费用!
举报微信:13140028228 冯老师

态度公正、信息求实、投稿自助、使用免费
您的位置:学术资讯 » 正文
  • 阅读: 2022/10/27 14:38:37

    两个数据集,一个点文件FeatureCollection,另一个Landsat8影像数据ImageCollection,现在遍历点文件中的每一个点,提取这个点位上所有影像的栅格值(波段值),并导出为csv,适用。

    代码:

    var firstlyr = ee.FeatureCollection("users/points");

    var fqshp = ee.FeatureCollection("users/boundary");

    function maskL8sr(image) {

    // Bit 0 - Fill

    // Bit 1 - Dilated Cloud

    // Bit 2 - Cirrus

    // Bit 3 - Cloud

    // Bit 4 - Cloud Shadow

    var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0);

    var saturationMask = image.select('QA_RADSAT').eq(0);

    // Apply the scaling factors to the appropriate bands.

    var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);

    var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);

    // Replace the original bands with the scaled ones and apply the masks.

    return image.addBands(opticalBands, null, true)

    .addBands(thermalBands, null, true)

    .updateMask(qaMask)

    .updateMask(saturationMask);

    }

    // Map the function over one year of data.

    var dataset = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')

    .filterDate('2021-01-01', '2021-02-01')

    .filterBounds(fqshp)

    .map(maskL8sr);

    print('images number:',dataset.size());

    print(dataset);

    var mapfunc = function(feat) {

    var geom = feat.geometry();

    var addProp = function(img, f) {

    var newf = ee.Feature(f);

    var values = img.reduceRegion({

    reducer:ee.Reducer.first(),

    geometry:geom,

    scale:30,

    maxPixels:1e11});

    var values_array = ee.Algorithms.If(

    values.get('SR_B1'),

    values.toArray(['SR_B1','SR_B2','SR_B3','SR_B4','SR_B5','SR_B6','SR_B7']),

    9999);

    var fields_name = ee.String(img.get('system:index'));

    return ee.Feature(newf.setMulti(ee.Dictionary.fromLists(ee.List([fields_name]),ee.List([values_array]))));

    };

    var newfeat = ee.Feature(dataset.iterate(addProp, feat));

    return newfeat;

    };

    var newft = firstlyr.map(mapfunc);

    Export.table.toDrive({

    collection: newft,

    description: 'newft',

    fileFormat:'CSV',

    folder:'newft',

    fileNamePrefix:'newft'});

    print('done!');

    转自:科研萌新”微信公众号

    如有侵权,请联系本站删除!


    浏览(921)
    点赞(0)
    收藏(0)

上一篇:复现NC文章华夫图(方块图)-华丽展示实验样本构成

下一篇:顶刊分享|STE:六个气候多样城市内地表温度趋势的时空异质性