This directory contains the Google Earth Engine JavaScript code for satellite-based water balance computation and AWD suitability assessment. The script processes CHIRPS rainfall, MODIS evapotranspiration, and SoilGrids soil data to produce dekad-level (10-day) water balance maps.
- Google Earth Engine Account: Sign up at https://earthengine.google.com/
- Google Drive Account: For storing exported results
- Study Area Assets: Define rice extent boundaries (see "Preparing Study Area Data" below)
- Go to Google Earth Engine Code Editor
- Create a new script and copy the contents of
water_balance_suitability.js - Or import the shared script (coming soon)
At the top of the script, modify the configuration block:
// CONFIGURATION
var CONFIG = {
year: 2022, // Analysis year
season: {dekad_start: 10, dekad_end: 28}, // Season (dekad 10-28 = May-Sep)
exclusion_windows: {exclude_first: 2, exclude_last: 1}, // Exclude establishment/harvest phases
deficit_thresholds: [-25, -50, -70, -90, -110, -130, -150], // Deficit thresholds (mm)
irrigation_threshold: 5.0, // Min rainfall threshold (mm)
output_scale: 500, // Output resolution (meters)
max_pixels: 1e13 // Max processing area
};
// STUDY AREA (replace with your rice extent)
var rice_map = ee.Image("users/your-username/japan_rice_2020");Option A: Use User Asset (Recommended)
If you have a pre-processed rice extent map:
var rice_map = ee.Image("users/[your-username]/japan_rice_2020");Where the image contains values 1=rice, 0=other.
Option B: Use Existing MODIS Crop Classification
// MODIS Global Crop Classification (MOD12Q1)
var lulc = ee.ImageCollection("MODIS/061/MCD12Q1")
.filterDate(CONFIG.year + "-01-01", CONFIG.year + "-12-31")
.first()
.select("LC_Type1");
// Class 10 = Croplands (includes rice)
var rice_map = lulc.eq(10);Option C: Use ESA WorldCover
var worldcover = ee.ImageCollection("ESA/WorldCover/v100")
.filterDate(CONFIG.year + "-01-01", CONFIG.year + "-12-31")
.first();
// Class 40 = Croplands
var rice_map = worldcover.eq(40);- Click Run in the top-right corner
- Monitor progress in the Tasks panel
- Once data is ready, the script will start exporting results (see Tasks tab)
- Click Tasks tab in the GEE Editor (upper right)
- For each export task:
- Click Run to start export
- Check Google Drive folder specified in config (default: "AWD")
- Download .tif files
Expected output files:
Japan_AWD_Suitability_All_Thresholds.tif(multi-band image)
- Format: GeoTIFF (Cloud-optimized)
- Bands: 7 bands (one per threshold)
- Band 1:
suitability_-25(most lenient threshold) - Band 2:
suitability_-50 - ...
- Band 7:
suitability_-150(most stringent threshold)
- Band 1:
- Values: 1-3 (suitability class)
- 1 = Low suitability (<33% suitable dekads)
- 2 = Moderate suitability (33-66% suitable dekads)
- 3 = High suitability (>66% suitable dekads)
- Projection: EPSG:4326 (WGS84)
- Resolution: 500 m (as configured)
For each pixel, values across bands show how suitability classification changes with deficit threshold stringency:
Threshold: -25mm -50mm -70mm -90mm -110mm -130mm -150mm
Example Pixel: 3 3 2 2 1 1 1
This pixel has high suitability under lenient thresholds but drops to low suitability as threshold becomes more stringent. Use as basis for robustness assessment.
- Collection:
UCSB-CHG/CHIRPS/DAILY - Resolution: 5 km
- Temporal Coverage: 1981-present (daily)
- Processing in Script:
- Filter to study area and season dates
- Sum 10-day windows to dekad totals
- Output units: mm/dekad
// Example access:
var chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY")
.filterDate("2022-05-01", "2022-09-30")
.filterBounds(study_area_boundary);- Collection:
MODIS/061/MOD16A2 - Resolution: 500 m
- Temporal Coverage: 2000-present (8-day)
- Processing in Script:
- Reproject to 500m study grid
- Convert from 0.1 mm/8-day scale to mm/dekad
- Weighted overlap interpolation when dekad boundary crosses 8-day tile boundary
- Output units: mm/dekad
// Example access:
var modis_et = ee.ImageCollection("MODIS/061/MOD16A2")
.filterDate("2022-05-01", "2022-09-30");- Collections:
projects/soilgrids-isric/clay_mean(clay percentage 0-5cm)projects/soilgrids-isric/sand_mean(sand percentage 0-5cm)
- Resolution: 250 m
- Processing in Script:
- Calculate clay + sand percentages
- Classify into 4 texture classes
- Map texture class to percolation rate (3-12 mm/day)
- Convert to dekad totals
- Output units: mm/dekad
// Example access:
var clay = ee.Image("projects/soilgrids-isric/clay_mean").divide(10); // 0-100%- Collection:
USGS/SRTMGL1_Ellip - Resolution: 30 m
- Processing in Script:
- Used to compute slope for biophysical constraints
- Slope threshold: <10° for feasibility
- Output units: degrees
// Example access:
var dem = ee.Image("USGS/SRTMGL1_Ellip");
var slope = ee.Terrain.slope(dem);- User-provided or derived from MODIS/ESA classification
- Expected values: 1 (rice) or 0 (other)
- Resolution: Any (will be resampled to 500m)
Edit the deficit_thresholds array in CONFIG to test different water stress levels:
deficit_thresholds: [-10, -30, -50, -80, -120, -200], // Custom thresholdsLower (more negative) values = stricter criterion = fewer suitable dekads.
Change the year parameter:
year: 2020, // Or 2019, 2021, etc.The script will automatically adjust all date filters.
Change output_scale for coarser/finer output:
output_scale: 1000, // 1 km resolution (faster)
// or
output_scale: 250, // 250 m resolution (slower, more detail)Higher resolution increases computation time exponentially.
Replace the rice_map definition to use alternative data sources:
// Option 1: ESA WorldCover 2021 (global, high quality)
var worldcover = ee.ImageCollection("ESA/WorldCover/v200")
.filterDate("2021-01-01", "2021-12-31")
.first()
.select("Map");
var rice_map = worldcover.eq(40); // Class 40 = Croplands
// Option 2: MODIS LC (annual, consistent time series)
var modis_lc = ee.ImageCollection("MODIS/061/MCD12Q1")
.filterDate(CONFIG.year + "-01-01", CONFIG.year + "-12-31")
.first()
.select("LC_Type1");
var rice_map = modis_lc.eq(10); // Class 10 = Croplands
// Option 3: Custom asset (best for regional studies)
var rice_map = ee.Image("users/your-username/japan_rice_paddy_map_2020");Causes:
- Study area boundary doesn't overlap with rice extent
- Year has no data for selected collections
- Bounding box coordinates are inverted
Solutions:
- Verify bounding box:
[min_lon, min_lat, max_lon, max_lat] - Check that min_lon < max_lon and min_lat < max_lat
- Try expanding the study area boundary
- Verify year is within CHIRPS coverage (1981-present)
Causes:
- Study area too large (>1e13 pixels at 500m = ~2.5 million km²)
- Output resolution too fine (250m with large area)
- Too many thresholds being processed
Solutions:
- Reduce study area or increase
output_scale(coarsen resolution) - Reduce number of thresholds in
deficit_thresholds - Split analysis into smaller regions
- Use export.image.toDrive with default pyramid policy
Causes:
- Not logged into Google Earth Engine
- Missing access to shared datasets
Solutions:
- Click "Authorize" when prompted by GEE
- Ensure you have a Google Earth Engine account (request access at https://earthengine.google.com/signup/)
- If using user assets, verify ownership
// Option 1: Reduce spatial resolution
output_scale: 1000 // Default 500m, use 1000m for faster preview
// Option 2: Reduce study area
var study_region = ee.Geometry.rectangle([130, 30, 135, 35]); // Smaller area
// Option 3: Use fewer thresholds
deficit_thresholds: [-50, -100, -150] // Instead of 7 thresholdsLook at the GEE console (bottom-right) to see:
- Number of tiles being processed
- Current dekad being analyzed
- Estimated remaining time
After downloading GeoTIFF from Google Drive:
- Place in
data/raw/gee_exports/ - Run Python pipeline:
python scripts/run_pipeline.py
- Pipeline will automatically load and post-process the GEE outputs
- GEE Documentation: https://developers.google.com/earth-engine
- GEE Datasets: https://developers.google.com/earth-engine/datasets
- CHIRPS Data Guide: https://www.chg.ucsb.edu/data/chirps
- MODIS PET Guide: https://lpdaac.usgs.gov/products/mod16a2v061/
- SoilGrids Info: https://www.isric.org/explore/soilgrids
If you use this GEE script, please cite:
@software{tran_awd_gee_2025,
title={Google Earth Engine Pipeline for AWD Policy Transportability Assessment},
author={Tran, My},
year={2025},
url={https://github.com/MyTran-GitHub/awd-policy-transportability/tree/main/gee}
}Last Updated: January 2025