Didn't show all the column while export the CSV file while using google earth engine Planned...
How much damage would a cupful of neutron star matter do to the Earth?
Did Deadpool rescue all of the X-Force?
What are the out-of-universe reasons for the references to Toby Maguire-era Spider-Man in Into the Spider-Verse?
Why is the AVR GCC compiler using a full `CALL` even though I have set the `-mshort-calls` flag?
How to compare two different files line by line in unix?
An adverb for when you're not exaggerating
How to write this math term? with cases it isn't working
Performance gap between vector<bool> and array
Sum letters are not two different
Amount of permutations on an NxNxN Rubik's Cube
Do any jurisdictions seriously consider reclassifying social media websites as publishers?
Can a new player join a group only when a new campaign starts?
Why do we bend a book to keep it straight?
Maximum summed subsequences with non-adjacent items
Chinese Seal on silk painting - what does it mean?
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
ArcGIS Pro Python arcpy.CreatePersonalGDB_management
How to install press fit bottom bracket into new frame
What is this clumpy 20-30cm high yellow-flowered plant?
How often does castling occur in grandmaster games?
How do I find out the mythology and history of my Fortress?
Is it fair for a professor to grade us on the possession of past papers?
Do wooden building fires get hotter than 600°C?
Is CEO the "profession" with the most psychopaths?
Didn't show all the column while export the CSV file while using google earth engine
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;
}
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.
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?
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
New contributor
add a comment |
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.
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?
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
New contributor
Welcome to GIS SE. As a new user, please take the Tour which emphasizes the importance of asking One question per Question. Please Edit your question to focus on your most pressing question.
– Vince
3 hours ago
Just edited, thank you.
– Yu-Fen Huang
3 hours ago
Your title still has an 'and' in it; this indicates multiple questions
– Vince
19 mins ago
Sorry I thought I deleted it already. Thanks for keeping an eye
– Yu-Fen Huang
7 mins ago
add a comment |
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.
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?
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
New contributor
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.
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?
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
google-earth-engine loop landsat-8 satellite
New contributor
New contributor
edited 4 mins ago
Yu-Fen Huang
New contributor
asked 4 hours ago
Yu-Fen HuangYu-Fen Huang
12
12
New contributor
New contributor
Welcome to GIS SE. As a new user, please take the Tour which emphasizes the importance of asking One question per Question. Please Edit your question to focus on your most pressing question.
– Vince
3 hours ago
Just edited, thank you.
– Yu-Fen Huang
3 hours ago
Your title still has an 'and' in it; this indicates multiple questions
– Vince
19 mins ago
Sorry I thought I deleted it already. Thanks for keeping an eye
– Yu-Fen Huang
7 mins ago
add a comment |
Welcome to GIS SE. As a new user, please take the Tour which emphasizes the importance of asking One question per Question. Please Edit your question to focus on your most pressing question.
– Vince
3 hours ago
Just edited, thank you.
– Yu-Fen Huang
3 hours ago
Your title still has an 'and' in it; this indicates multiple questions
– Vince
19 mins ago
Sorry I thought I deleted it already. Thanks for keeping an eye
– Yu-Fen Huang
7 mins ago
Welcome to GIS SE. As a new user, please take the Tour which emphasizes the importance of asking One question per Question. Please Edit your question to focus on your most pressing question.
– Vince
3 hours ago
Welcome to GIS SE. As a new user, please take the Tour which emphasizes the importance of asking One question per Question. Please Edit your question to focus on your most pressing question.
– Vince
3 hours ago
Just edited, thank you.
– Yu-Fen Huang
3 hours ago
Just edited, thank you.
– Yu-Fen Huang
3 hours ago
Your title still has an 'and' in it; this indicates multiple questions
– Vince
19 mins ago
Your title still has an 'and' in it; this indicates multiple questions
– Vince
19 mins ago
Sorry I thought I deleted it already. Thanks for keeping an eye
– Yu-Fen Huang
7 mins ago
Sorry I thought I deleted it already. Thanks for keeping an eye
– Yu-Fen Huang
7 mins ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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-while-using-google-earth-en%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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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-while-using-google-earth-en%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Welcome to GIS SE. As a new user, please take the Tour which emphasizes the importance of asking One question per Question. Please Edit your question to focus on your most pressing question.
– Vince
3 hours ago
Just edited, thank you.
– Yu-Fen Huang
3 hours ago
Your title still has an 'and' in it; this indicates multiple questions
– Vince
19 mins ago
Sorry I thought I deleted it already. Thanks for keeping an eye
– Yu-Fen Huang
7 mins ago