diff --git a/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections b/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections index bb2bc249..746718ff 100644 --- a/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections +++ b/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections @@ -8,7 +8,7 @@ // We create a NDVI time-series and export each // image as a separate GeoTiff file -var s2 = ee.ImageCollection("COPERNICUS/S2_HARMONIZED/"); +var s2 = ee.ImageCollection("COPERNICUS/S2_HARMONIZED"); var geometry = ee.Geometry.Polygon([[ [82.60642647743225, 27.16350437805251], [82.60984897613525, 27.1618529901377], @@ -47,7 +47,6 @@ function addNDVI(image) { var withNdvi = filtered.map(addNDVI); var exportCol = withNdvi.select('ndvi'); - // The function below exports the collection // The key is to use 'evaluate()' to asynchronously get a list // if image ids and start an export task for each image diff --git a/docs/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections b/docs/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections index bb2bc249..746718ff 100644 --- a/docs/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections +++ b/docs/code/end_to_end_gee/Supplement/Image_Collections/Exporting_ImageCollections @@ -8,7 +8,7 @@ // We create a NDVI time-series and export each // image as a separate GeoTiff file -var s2 = ee.ImageCollection("COPERNICUS/S2_HARMONIZED/"); +var s2 = ee.ImageCollection("COPERNICUS/S2_HARMONIZED"); var geometry = ee.Geometry.Polygon([[ [82.60642647743225, 27.16350437805251], [82.60984897613525, 27.1618529901377], @@ -47,7 +47,6 @@ function addNDVI(image) { var withNdvi = filtered.map(addNDVI); var exportCol = withNdvi.select('ndvi'); - // The function below exports the collection // The key is to use 'evaluate()' to asynchronously get a list // if image ids and start an export task for each image diff --git a/docs/end-to-end-gee-supplement.html b/docs/end-to-end-gee-supplement.html index 329cf338..3d46deba 100644 --- a/docs/end-to-end-gee-supplement.html +++ b/docs/end-to-end-gee-supplement.html @@ -2849,7 +2849,7 @@

Exporting ImageCollections

// We create a NDVI time-series and export each // image as a separate GeoTiff file -var s2 = ee.ImageCollection("COPERNICUS/S2_HARMONIZED/"); +var s2 = ee.ImageCollection("COPERNICUS/S2_HARMONIZED"); var geometry = ee.Geometry.Polygon([[ [82.60642647743225, 27.16350437805251], [82.60984897613525, 27.1618529901377], @@ -2888,43 +2888,42 @@

Exporting ImageCollections

var withNdvi = filtered.map(addNDVI); var exportCol = withNdvi.select('ndvi'); - -// The function below exports the collection -// The key is to use 'evaluate()' to asynchronously get a list -// if image ids and start an export task for each image - -var doExport = function() { - print('Working') - var ids = exportCol.aggregate_array('system:index'); - // evaluate() will not block the UI and once the result is available - // will be passed-on to the callback function where we will call - // Export.image.toDrive() - ids.evaluate(function(imageIds) { - print('Total number of images', imageIds.length) - print('Exporting now... (see Tasks tab)') - print('Tip: Use Ctrl+Click/Cmd+Click on tasks to skip confirmation.') - for(var i = 0; i < imageIds.length; i++) { - - // Filter using the image id - var image = ee.Image(exportCol.toList(1, i).get(0)); - - Export.image.toDrive({ - image: image, - region: geometry, - scale: 10, - fileNamePrefix: imageIds[i], - folder: 'earthengine', - description: 'Export_' + i + '_' + imageIds[i], - }) - } - }) - -} - -print('Click button below to start export') -var button = ui.Button({label: 'Export', onClick: doExport}) -print(button) -Map.centerObject(geometry); +// The function below exports the collection +// The key is to use 'evaluate()' to asynchronously get a list +// if image ids and start an export task for each image + +var doExport = function() { + print('Working') + var ids = exportCol.aggregate_array('system:index'); + // evaluate() will not block the UI and once the result is available + // will be passed-on to the callback function where we will call + // Export.image.toDrive() + ids.evaluate(function(imageIds) { + print('Total number of images', imageIds.length) + print('Exporting now... (see Tasks tab)') + print('Tip: Use Ctrl+Click/Cmd+Click on tasks to skip confirmation.') + for(var i = 0; i < imageIds.length; i++) { + + // Filter using the image id + var image = ee.Image(exportCol.toList(1, i).get(0)); + + Export.image.toDrive({ + image: image, + region: geometry, + scale: 10, + fileNamePrefix: imageIds[i], + folder: 'earthengine', + description: 'Export_' + i + '_' + imageIds[i], + }) + } + }) + +} + +print('Click button below to start export') +var button = ui.Button({label: 'Export', onClick: doExport}) +print(button) +Map.centerObject(geometry);

Get Pixelwise Dates for Composites

diff --git a/docs/gee-water-resources-management-supplement.html b/docs/gee-water-resources-management-supplement.html index ec898893..15c6f5a3 100644 --- a/docs/gee-water-resources-management-supplement.html +++ b/docs/gee-water-resources-management-supplement.html @@ -438,6 +438,9 @@

MODIS 16-Day VCI

href="https://courses.spatialthoughts.com/gee-water-resources-management.html#drought-monitoring">Drought Monitoring script that uses 16-day composites instead of monthly composites.

+

Open in Code Editor ↗

// Example script showing VCI computation
 // for each 16-day period of MODIS composites
 
@@ -544,6 +547,9 @@ 

MODIS 16-Day VCI

Pie Chart Group Statistics

+

Open in Code Editor ↗

var modis = ee.ImageCollection("MODIS/006/MOD13Q1");
 var gfsad = ee.Image("USGS/GFSAD1000_V1");
 
@@ -739,6 +745,9 @@ 

Pie Chart Group Statistics

Hydrology

Chart Cumulative Rainfall

+

Open in Code Editor ↗

var chirpsDaily = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY");
 
 // Define a water year
@@ -788,6 +797,9 @@ 

Chart Cumulative Rainfall

Exporting Precipitation Data

+

Open in Code Editor ↗

// This script demonstrates how to create and export
 // country/continent-wide precipitation data from CHIRPS
 // The goal is to create 1 yearly image with 12 bands -
@@ -851,6 +863,9 @@ 

Exporting Precipitation Data

GPM Precipitation Time Series

+

Open in Code Editor ↗

/**** Start of imports. If edited, may not auto-convert in the playground. ****/
 var gpm = ee.ImageCollection("NASA/GPM_L3/IMERG_V06");
 /***** End of imports. If edited, may not auto-convert in the playground. *****/
@@ -891,6 +906,9 @@ 

GPM Precipitation Time Series

IMD Number of Rainy Days

+

Open in Code Editor ↗

// Calculate Total Number of Rainy Days in a Year per Pixel
 
 // IMD Collection is a processed version of raw IMD Rainfall Images
@@ -927,6 +945,9 @@ 

IMD Number of Rainy Days

Surface Water

Detect First Year of Water

+

Open in Code Editor ↗

// This script shows how to determine when the water appeared 
 // for the first time at a given pixel
 var gswYearly = ee.ImageCollection("JRC/GSW1_3/YearlyHistory") 
@@ -1001,6 +1022,9 @@ 

Detect First Year of Water

Otsu Dynamic Thresholding

+

Open in Code Editor ↗

var admin2 = ee.FeatureCollection("FAO/GAUL_SIMPLIFIED_500m/2015/level2");
 var s2 = ee.ImageCollection("COPERNICUS/S2_SR");
 
@@ -1181,6 +1205,9 @@ 

Otsu Dynamic Thresholding

Smoothing Vectors

+

Open in Code Editor ↗

var gsw = ee.Image("JRC/GSW1_3/GlobalSurfaceWater");
 var hydrobasins = ee.FeatureCollection("WWF/HydroSHEDS/v1/Basins/hybas_7");
 var basin = hydrobasins.filter(ee.Filter.eq('HYBAS_ID', 4071139640))
@@ -1222,6 +1249,9 @@ 

Smoothing Vectors

Surface Water Explorer Split Panel App

+

Open in Code Editor ↗

var admin2 = ee.FeatureCollection("FAO/GAUL_SIMPLIFIED_500m/2015/level2");
 var gswYearly = ee.ImageCollection("JRC/GSW1_3/YearlyHistory");
@@ -1358,6 +1388,9 @@ 

Surface Water Explorer Split Panel App

Unsupervised Clustering

+

Open in Code Editor ↗

/*
 GEE adaptation of the 'waterdetect' algorithm
@@ -1514,6 +1547,9 @@ 

Sentinel-1 ARD Pre-Processing

Gamma MAP Speckle filtering

+

Open in Code Editor ↗

// Example script that shows how to pre-process SAR data
 // using Analysis Ready Data (ARD) Framework from
@@ -1609,6 +1645,9 @@ 

Sentinel-1 ARD Pre-Processing

Time Series Analysis

Mann Kendall Test

+

Open in Code Editor ↗

var taluks = ee.FeatureCollection("users/ujavalgandhi/gee-water-resources/kgis_taluks");
 var chirps = ee.ImageCollection('UCSB-CHG/CHIRPS/PENTAD')