didn't show all the column while export the csv file and how to use map Planned maintenance...

Can the Great Weapon Master feat's "Power Attack" apply to attacks from the Spiritual Weapon spell?

How often does castling occur in grandmaster games?

What's the meaning of "fortified infraction restraint"?

What does it mean that physics no longer uses mechanical models to describe phenomena?

How to react to hostile behavior from a senior developer?

Why is Nikon 1.4g better when Nikon 1.8g is sharper?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Amount of permutations on an NxNxN Rubik's Cube

Should I use a zero-interest credit card for a large one-time purchase?

If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?

Trademark violation for app?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

What is this clumpy 20-30cm high yellow-flowered plant?

How to install press fit bottom bracket into new frame

How to tell that you are a giant?

Is it fair for a professor to grade us on the possession of past papers?

Localisation of Category

Can a new player join a group only when a new campaign starts?

What is the topology associated with the algebras for the ultrafilter monad?

Why aren't air breathing engines used as small first stages?

Dating a Former Employee

Take 2! Is this homebrew Lady of Pain warlock patron balanced?

NumericArray versus PackedArray in MMA12

What would you call this weird metallic apparatus that allows you to lift people?



didn't show all the column while export the csv file and how to use map



Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Count the number of pixel identified as water from a collection of landsat imageTrying to map through and reduce regions of image using Google Earth Engine?Reducer.sum() gives all zeros where file has values that display on the mapGoogle Earth Engine, how to distinguish between rivers/streams and ponds/lakes in a water maskIterating an Earth Engine calculation (reducer) over every country in the world: a simple exampleApplying a reducer over a very large featureCreate time series and export it to csv GEEHow can I add a featureCollection to another one to export into one sigle .csv file?Can you both export and use a variable in the same GEE script?Calculating intersect for two featurecollections





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I met one problem about export .csv and need suggestions about looping for my code. I'm trying to calculate the water areas and the statistics of each band for each water areas to see if there are seasonal changes.




  1. The exported .csv file only have the columns ("GNIS_ID","AreaSqKm","waterArea") before join. I printed the variable, Join, and it does have all the column I need. How come they didn't show in the exported csv file? Did I miss something?


  2. My next step will need to loop the code by month in order to export the water areas and their statistics by month from 2014 to 2018, I've been tried using map and with my code, but it didn't seem to work.



Sorry that this is my first GEE script, so it's very messy, if there is any better way to write it, please let me know, I appreciate a lot.



Thank you!



    var CollectMonth = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(HI_poly)
.sort('CLOUD_COVER')
.filterDate('2014-01-01', '2014-01-30')
.map(function(image){return image.clip(USGS_WBD)}) // clip the images by the;
print(CollectMonth);

// Calculate Water Area
var waterThreshold = 324;

var WaterAreaFunction = function(image){
//add the water band to the image
var water = image.select(['pixel_qa']).rename('water');
//get pixels equal the threshold
var water01 = water.eq(waterThreshold);
//mask those pixels from the image
image = image.updateMask(water01).addBands(water);

var area = ee.Image.pixelArea();
var waterArea = water01.multiply(area).rename('waterArea');

image = image.addBands(waterArea);

var stats = waterArea.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: USGS_WBD,
scale: 30,
});

return image.set(stats);
};

var l8Mosaic = CollectMonth.map(WaterAreaFunction).mosaic().multiply(0.0001);
var l8Mosaic_area = l8Mosaic.divide(1000000)

//statistics
var WBD_area = l8Mosaic_area.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.sum(),
scale: 30 // resolution
}).select(["GNIS_ID","AreaSqKm","waterArea"]);
print("area:",WBD_area);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
var WBD_mean = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.mean(),
scale: 30 // resolution
}).select(["GNIS_ID","B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
print("mean:",WBD_mean);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
var WBD_median = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.median(),
scale: 30 // resolution
}).select(["GNIS_ID","B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
print("median:",WBD_median);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
var WBD_min = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.min(),
scale: 30 // resolution
}).select(["GNIS_ID","B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
print("min:",WBD_min);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
var WBD_max = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.max(),
scale: 30 // resolution
}).select(["GNIS_ID","B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
print("max:",WBD_max);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
var WBD10 = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.percentile([10]),
scale: 30 // resolution
}).select(["GNIS_ID","B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
print("WBD10:",WBD10);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
var WBD90 = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.percentile([90]),
scale: 30 // resolution
}).select(["GNIS_ID","B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
print("WBD90:",WBD90);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
var WBD_std = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.stdDev(),
scale: 30 // resolution
}).select(["GNIS_ID","B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
print("std:",WBD_std);

var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
.rename(["B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
var WBD_variance = WBD_value.reduceRegions({
collection: USGS_WBD,
reducer: ee.Reducer.variance(),
scale: 30 // resolution
}).select(["GNIS_ID","B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
print("variance:",WBD_variance);


// =============== Join ============================
// Join two collection
// Use an equals filter to define how the collections match.
var filter = ee.Filter.equals({
leftField: 'GNIS_ID',
rightField: 'GNIS_ID'
});

// Define the join.
var innerJoin = ee.Join.inner();

// Apply the join.
var Join = innerJoin.apply(WBD_area, WBD_mean, filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// Apply the join.
var Join = innerJoin.apply(Join, WBD_median,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// // Apply the join.
var Join = innerJoin.apply(Join, WBD_min,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// // Apply the join.
var Join = innerJoin.apply(Join, WBD_max,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// // Apply the join.
var Join = innerJoin.apply(Join, WBD10,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// // Apply the join.
var Join = innerJoin.apply(Join, WBD90,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// // Apply the join.
var Join = innerJoin.apply(Join, WBD_std,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});

// // Apply the join.
var Join = innerJoin.apply(Join, WBD_variance,filter);
Join = Join.map(function(pair) {
var f1 = ee.Feature(pair.get('primary'));
var f2 = ee.Feature(pair.get('secondary'));
return f1.set(f2.toDictionary());
});
print(Join)

// Export the FeatureCollection.
Export.table.toDrive({
collection: Join,
description: 'Monthly_Lansat8_SR',
fileFormat: 'CSV'
});








share







New contributor




Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I met one problem about export .csv and need suggestions about looping for my code. I'm trying to calculate the water areas and the statistics of each band for each water areas to see if there are seasonal changes.




    1. The exported .csv file only have the columns ("GNIS_ID","AreaSqKm","waterArea") before join. I printed the variable, Join, and it does have all the column I need. How come they didn't show in the exported csv file? Did I miss something?


    2. My next step will need to loop the code by month in order to export the water areas and their statistics by month from 2014 to 2018, I've been tried using map and with my code, but it didn't seem to work.



    Sorry that this is my first GEE script, so it's very messy, if there is any better way to write it, please let me know, I appreciate a lot.



    Thank you!



        var CollectMonth = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
    .filterBounds(HI_poly)
    .sort('CLOUD_COVER')
    .filterDate('2014-01-01', '2014-01-30')
    .map(function(image){return image.clip(USGS_WBD)}) // clip the images by the;
    print(CollectMonth);

    // Calculate Water Area
    var waterThreshold = 324;

    var WaterAreaFunction = function(image){
    //add the water band to the image
    var water = image.select(['pixel_qa']).rename('water');
    //get pixels equal the threshold
    var water01 = water.eq(waterThreshold);
    //mask those pixels from the image
    image = image.updateMask(water01).addBands(water);

    var area = ee.Image.pixelArea();
    var waterArea = water01.multiply(area).rename('waterArea');

    image = image.addBands(waterArea);

    var stats = waterArea.reduceRegion({
    reducer: ee.Reducer.sum(),
    geometry: USGS_WBD,
    scale: 30,
    });

    return image.set(stats);
    };

    var l8Mosaic = CollectMonth.map(WaterAreaFunction).mosaic().multiply(0.0001);
    var l8Mosaic_area = l8Mosaic.divide(1000000)

    //statistics
    var WBD_area = l8Mosaic_area.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.sum(),
    scale: 30 // resolution
    }).select(["GNIS_ID","AreaSqKm","waterArea"]);
    print("area:",WBD_area);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
    var WBD_mean = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.mean(),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
    print("mean:",WBD_mean);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
    var WBD_median = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.median(),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
    print("median:",WBD_median);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
    var WBD_min = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.min(),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
    print("min:",WBD_min);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
    var WBD_max = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.max(),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
    print("max:",WBD_max);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
    var WBD10 = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.percentile([10]),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
    print("WBD10:",WBD10);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
    var WBD90 = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.percentile([90]),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
    print("WBD90:",WBD90);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
    var WBD_std = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.stdDev(),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
    print("std:",WBD_std);

    var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
    .rename(["B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
    var WBD_variance = WBD_value.reduceRegions({
    collection: USGS_WBD,
    reducer: ee.Reducer.variance(),
    scale: 30 // resolution
    }).select(["GNIS_ID","B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
    print("variance:",WBD_variance);


    // =============== Join ============================
    // Join two collection
    // Use an equals filter to define how the collections match.
    var filter = ee.Filter.equals({
    leftField: 'GNIS_ID',
    rightField: 'GNIS_ID'
    });

    // Define the join.
    var innerJoin = ee.Join.inner();

    // Apply the join.
    var Join = innerJoin.apply(WBD_area, WBD_mean, filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // Apply the join.
    var Join = innerJoin.apply(Join, WBD_median,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // // Apply the join.
    var Join = innerJoin.apply(Join, WBD_min,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // // Apply the join.
    var Join = innerJoin.apply(Join, WBD_max,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // // Apply the join.
    var Join = innerJoin.apply(Join, WBD10,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // // Apply the join.
    var Join = innerJoin.apply(Join, WBD90,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // // Apply the join.
    var Join = innerJoin.apply(Join, WBD_std,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });

    // // Apply the join.
    var Join = innerJoin.apply(Join, WBD_variance,filter);
    Join = Join.map(function(pair) {
    var f1 = ee.Feature(pair.get('primary'));
    var f2 = ee.Feature(pair.get('secondary'));
    return f1.set(f2.toDictionary());
    });
    print(Join)

    // Export the FeatureCollection.
    Export.table.toDrive({
    collection: Join,
    description: 'Monthly_Lansat8_SR',
    fileFormat: 'CSV'
    });








    share







    New contributor




    Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I met one problem about export .csv and need suggestions about looping for my code. I'm trying to calculate the water areas and the statistics of each band for each water areas to see if there are seasonal changes.




      1. The exported .csv file only have the columns ("GNIS_ID","AreaSqKm","waterArea") before join. I printed the variable, Join, and it does have all the column I need. How come they didn't show in the exported csv file? Did I miss something?


      2. My next step will need to loop the code by month in order to export the water areas and their statistics by month from 2014 to 2018, I've been tried using map and with my code, but it didn't seem to work.



      Sorry that this is my first GEE script, so it's very messy, if there is any better way to write it, please let me know, I appreciate a lot.



      Thank you!



          var CollectMonth = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
      .filterBounds(HI_poly)
      .sort('CLOUD_COVER')
      .filterDate('2014-01-01', '2014-01-30')
      .map(function(image){return image.clip(USGS_WBD)}) // clip the images by the;
      print(CollectMonth);

      // Calculate Water Area
      var waterThreshold = 324;

      var WaterAreaFunction = function(image){
      //add the water band to the image
      var water = image.select(['pixel_qa']).rename('water');
      //get pixels equal the threshold
      var water01 = water.eq(waterThreshold);
      //mask those pixels from the image
      image = image.updateMask(water01).addBands(water);

      var area = ee.Image.pixelArea();
      var waterArea = water01.multiply(area).rename('waterArea');

      image = image.addBands(waterArea);

      var stats = waterArea.reduceRegion({
      reducer: ee.Reducer.sum(),
      geometry: USGS_WBD,
      scale: 30,
      });

      return image.set(stats);
      };

      var l8Mosaic = CollectMonth.map(WaterAreaFunction).mosaic().multiply(0.0001);
      var l8Mosaic_area = l8Mosaic.divide(1000000)

      //statistics
      var WBD_area = l8Mosaic_area.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.sum(),
      scale: 30 // resolution
      }).select(["GNIS_ID","AreaSqKm","waterArea"]);
      print("area:",WBD_area);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
      var WBD_mean = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.mean(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
      print("mean:",WBD_mean);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
      var WBD_median = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.median(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
      print("median:",WBD_median);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
      var WBD_min = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.min(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
      print("min:",WBD_min);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
      var WBD_max = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.max(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
      print("max:",WBD_max);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
      var WBD10 = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.percentile([10]),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
      print("WBD10:",WBD10);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
      var WBD90 = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.percentile([90]),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
      print("WBD90:",WBD90);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
      var WBD_std = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.stdDev(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
      print("std:",WBD_std);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
      var WBD_variance = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.variance(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
      print("variance:",WBD_variance);


      // =============== Join ============================
      // Join two collection
      // Use an equals filter to define how the collections match.
      var filter = ee.Filter.equals({
      leftField: 'GNIS_ID',
      rightField: 'GNIS_ID'
      });

      // Define the join.
      var innerJoin = ee.Join.inner();

      // Apply the join.
      var Join = innerJoin.apply(WBD_area, WBD_mean, filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // Apply the join.
      var Join = innerJoin.apply(Join, WBD_median,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_min,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_max,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD10,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD90,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_std,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_variance,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });
      print(Join)

      // Export the FeatureCollection.
      Export.table.toDrive({
      collection: Join,
      description: 'Monthly_Lansat8_SR',
      fileFormat: 'CSV'
      });








      share







      New contributor




      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I met one problem about export .csv and need suggestions about looping for my code. I'm trying to calculate the water areas and the statistics of each band for each water areas to see if there are seasonal changes.




      1. The exported .csv file only have the columns ("GNIS_ID","AreaSqKm","waterArea") before join. I printed the variable, Join, and it does have all the column I need. How come they didn't show in the exported csv file? Did I miss something?


      2. My next step will need to loop the code by month in order to export the water areas and their statistics by month from 2014 to 2018, I've been tried using map and with my code, but it didn't seem to work.



      Sorry that this is my first GEE script, so it's very messy, if there is any better way to write it, please let me know, I appreciate a lot.



      Thank you!



          var CollectMonth = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
      .filterBounds(HI_poly)
      .sort('CLOUD_COVER')
      .filterDate('2014-01-01', '2014-01-30')
      .map(function(image){return image.clip(USGS_WBD)}) // clip the images by the;
      print(CollectMonth);

      // Calculate Water Area
      var waterThreshold = 324;

      var WaterAreaFunction = function(image){
      //add the water band to the image
      var water = image.select(['pixel_qa']).rename('water');
      //get pixels equal the threshold
      var water01 = water.eq(waterThreshold);
      //mask those pixels from the image
      image = image.updateMask(water01).addBands(water);

      var area = ee.Image.pixelArea();
      var waterArea = water01.multiply(area).rename('waterArea');

      image = image.addBands(waterArea);

      var stats = waterArea.reduceRegion({
      reducer: ee.Reducer.sum(),
      geometry: USGS_WBD,
      scale: 30,
      });

      return image.set(stats);
      };

      var l8Mosaic = CollectMonth.map(WaterAreaFunction).mosaic().multiply(0.0001);
      var l8Mosaic_area = l8Mosaic.divide(1000000)

      //statistics
      var WBD_area = l8Mosaic_area.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.sum(),
      scale: 30 // resolution
      }).select(["GNIS_ID","AreaSqKm","waterArea"]);
      print("area:",WBD_area);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
      var WBD_mean = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.mean(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_mean","B2_mean","B3_mean","B4_mean","B5_mean","B6_mean","B7_mean"])
      print("mean:",WBD_mean);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
      var WBD_median = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.median(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_median","B2_median","B3_median","B4_median","B5_median","B6_median","B7_median"])
      print("median:",WBD_median);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
      var WBD_min = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.min(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_min","B2_min","B3_min","B4_min","B5_min","B6_min","B7_min"])
      print("min:",WBD_min);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
      var WBD_max = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.max(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_max","B2_max","B3_max","B4_max","B5_max","B6_max","B7_max"])
      print("max:",WBD_max);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
      var WBD10 = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.percentile([10]),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_WBD10","B2_WBD10","B3_WBD10","B4_WBD10","B5_WBD10","B6_WBD10","B7_WBD10"])
      print("WBD10:",WBD10);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
      var WBD90 = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.percentile([90]),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_WBD90","B2_WBD90","B3_WBD90","B4_WBD90","B5_WBD90","B6_WBD90","B7_WBD90"])
      print("WBD90:",WBD90);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
      var WBD_std = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.stdDev(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_std","B2_std","B3_std","B4_std","B5_std","B6_std","B7_std"])
      print("std:",WBD_std);

      var WBD_value = l8Mosaic.select(["B1","B2","B3","B4","B5","B6","B7"])
      .rename(["B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
      var WBD_variance = WBD_value.reduceRegions({
      collection: USGS_WBD,
      reducer: ee.Reducer.variance(),
      scale: 30 // resolution
      }).select(["GNIS_ID","B1_variance","B2_variance","B3_variance","B4_variance","B5_variance","B6_variance","B7_variance"])
      print("variance:",WBD_variance);


      // =============== Join ============================
      // Join two collection
      // Use an equals filter to define how the collections match.
      var filter = ee.Filter.equals({
      leftField: 'GNIS_ID',
      rightField: 'GNIS_ID'
      });

      // Define the join.
      var innerJoin = ee.Join.inner();

      // Apply the join.
      var Join = innerJoin.apply(WBD_area, WBD_mean, filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // Apply the join.
      var Join = innerJoin.apply(Join, WBD_median,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_min,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_max,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD10,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD90,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_std,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });

      // // Apply the join.
      var Join = innerJoin.apply(Join, WBD_variance,filter);
      Join = Join.map(function(pair) {
      var f1 = ee.Feature(pair.get('primary'));
      var f2 = ee.Feature(pair.get('secondary'));
      return f1.set(f2.toDictionary());
      });
      print(Join)

      // Export the FeatureCollection.
      Export.table.toDrive({
      collection: Join,
      description: 'Monthly_Lansat8_SR',
      fileFormat: 'CSV'
      });






      google-earth-engine loop landsat-8 satellite





      share







      New contributor




      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      Yu-Fen HuangYu-Fen Huang

      1




      1




      New contributor




      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Yu-Fen Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Yu-Fen Huang is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f319300%2fdidnt-show-all-the-column-while-export-the-csv-file-and-how-to-use-map%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Yu-Fen Huang is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Yu-Fen Huang is a new contributor. Be nice, and check out our Code of Conduct.













          Yu-Fen Huang is a new contributor. Be nice, and check out our Code of Conduct.












          Yu-Fen Huang is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f319300%2fdidnt-show-all-the-column-while-export-the-csv-file-and-how-to-use-map%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          (145452) 2005 RN43 Классификация | Примечания | Ссылки |...

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Энтрерриос (город) Содержание История | Географическое...