Thursday, October 29, 2026

Using AI to download environmental variables from Google Earth Engine

 What are environmental variables? 

Remote sensing environmental variables are measurable properties of the Earth's land, water, and atmosphere captured using satellite, airborne, or ground-based sensors.

Environmental variables are sometimes called 'geophysical parameters' in remote sensing. When classified by international Earth observation frameworks (such as NASA Earthdata or the Global Climate Observing System), they are specifically referred to as Essential Climate Variables (ECVs) or Essential Variables (EVs) when used to monitor Earth's processes, land surface dynamics, and climate change.

The Google Earth Engine Data Catalog hosts a massive, multi-petabyte repository of geospatial data. The environmental variables accessible on the platform are structured across several main scientific categories: 

1. Atmosphere & Climate

Data parameters detailing the composition, dynamics, and short- to long-term conditions of the lower atmosphere: 

  • Temperature: Surface air temperature, land surface temperature (LST), maximum/minimum temperature, and ocean/sea surface temperature (SST).
  • Precipitation: Total rainfall, snowfall, convective precipitation, and rainfall intensity. 
  • Atmospheric Water & Humidity: Specific humidity, relative humidity, precipitable water vapor, and dewpoint temperature. 
  • Wind: Wind speed, wind vector components (u and v vectors), and gust speed. 
  • Radiation & Solar: Downwelling shortwave/longwave radiation, solar irradiance, and photosynthetically active radiation (PAR). 
  • Atmospheric Composition: Ozone levels, methane concentrations (CH₄), carbon dioxide (CO₂), nitrogen dioxide (NO₂), sulfur dioxide (SO₂), and aerosol optical depth (AOD). 
  • Derived Bioclimatic Indexes: 19 bioclimatic variables (e.g., from WorldClim) including annual mean temperature, seasonality, and precipitation of the driest/wettest quarters. 

2. Land Surface & Topography

Physical parameters of the Earth's crust, elevation, and terrain: 

  • Elevation & Topography: Digital Elevation Models (DEMs), slope, aspect, hillshade, terrain roughness, and topographic position index (TPI).
  • Soil Properties: Soil moisture (surface and root-zone), soil organic carbon, soil pH, bulk density, and sand/silt/clay fractions.
  • Land Use & Land Cover (LULC): Crop classification maps, global forest cover change, urban footprint, and global ecosystem classifications.
  • Geophysical Disturbance: Areas annually burned, active thermal anomalies (fires), and time-since-fire indices. 

3. Biosphere & Vegetation Indices

Variables indicating the distribution, health, and productivity of plant life: 

  • Vegetation Indices: Normalized Difference Vegetation Index (NDVI), Enhanced Vegetation Index (EVI), and Soil Adjusted Vegetation Index (SAVI).
  • Plant Productivity: Gross Primary Productivity (GPP), Net Primary Productivity (NPP), Fraction of Absorbed Photosynthetically Active Radiation (FAPAR), and Leaf Area Index (LAI).
  • Forest & Biomass: Tree canopy height, above-ground biomass, and canopy cover fraction. 

4. Hydrology & Cryosphere

Water dynamics on the surface and frozen landscapes: 

  • Surface and Ground Water: Surface water extent, river discharge, groundwater storage anomalies, and water quality indicators (chlorophyll-a, turbidity).
  • Evapotranspiration: Potential evapotranspiration (PET), actual evapotranspiration (ET), and latent heat flux.
  • Cryosphere (Ice & Snow): Snow water equivalent (SWE), snow cover extent, albedo, glacier velocity, and sea ice concentration. 

5. Human Dimensions & Infrastructure

Socio-environmental datasets representing human modification of landscapes: 

  • Human Footprint: Nighttime lights (radiance), population density, human modification index, and road network proximity. 


/**
 * 1. DEFINE YOUR STUDY AREA & TIME PERIOD
 * Replace 'geometry' below with your hand-drawn polygon or asset link if needed.
 */
// Default study area: A 20km square box around a sample point
var studyArea = ee.Geometry.Point([-122.25, 37.87]).buffer(20000); 
Map.centerObject(studyArea, 10);
Map.addLayer(studyArea, {color: 'red'}, 'Study Area Boundary', false);

var startDate = '2025-01-01';
var endDate = '2025-12-31';

/**
 * 2. LOAD & PROCESS ENVIRONMENTAL VARIABLES
 */

// --- Variable A: Temperature (ERA5-Land Mean Air Temperature) ---
var temp = ee.ImageCollection("ECMWF/ERA5_LAND/MONTHLY_AGGR")
  .filterBounds(studyArea)
  .filterDate(startDate, endDate)
  .select('temperature_2m')
  .mean() // Average over the year
  .subtract(273.15) // Convert Kelvin to Celsius
  .clip(studyArea)
  .rename('mean_temperature_celsius');

// --- Variable B: Precipitation (CHIRPS Daily Rainfall) ---
var precip = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY")
  .filterBounds(studyArea)
  .filterDate(startDate, endDate)
  .select('precipitation')
  .sum() // Total annual rainfall
  .clip(studyArea)
  .rename('total_precipitation_mm');

// --- Variable C: Soil Moisture (NASA USDA Global Soil Moisture) ---
var soilMoisture = ee.ImageCollection("NASA_USDA/HSL/SMAP10KM_soil_moisture")
  .filterBounds(studyArea)
  .filterDate(startDate, endDate)
  .select('ssm') // Surface soil moisture
  .mean()
  .clip(studyArea)
  .rename('surface_soil_moisture');

// --- Variable D: Topography (NASADEM Elevation) ---
var elevation = ee.Image("NASA/NASADEM_HGT/001")
  .select('elevation')
  .clip(studyArea)
  .rename('elevation_meters');

// --- Variable E: Vegetation Health (Sentinel-2 NDVI) ---
// Function to mask clouds in Sentinel-2
function maskS2clouds(image) {
  var qa = image.select('QA60');
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(qa.bitwiseAnd(cirrusBitMask).eq(0));
  return image.updateMask(mask).divide(10000);
}

var s2 = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED")
  .filterBounds(studyArea)
  .filterDate(startDate, endDate)
  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
  .map(maskS2clouds);

var ndvi = s2.median().normalizedDifference(['B8', 'B4']) // NIR and Red bands
  .clip(studyArea)
  .rename('ndvi_median');

/**
 * 3. VISUALIZE DATA LAYERS ON THE MAP
 */
Map.addLayer(temp, {min: 0, max: 35, palette: ['blue', 'yellow', 'red']}, 'Mean Temp (°C)');
Map.addLayer(precip, {min: 200, max: 2000, palette: ['brown', 'yellow', 'blue']}, 'Total Precip (mm)');
Map.addLayer(soilMoisture, {min: 0, max: 25, palette: ['red', 'yellow', 'green']}, 'Surface Soil Moisture');
Map.addLayer(elevation, {min: 0, max: 2000, palette: ['green', 'yellow', 'brown']}, 'Elevation (m)');
Map.addLayer(ndvi, {min: 0, max: 0.8, palette: ['white', 'yellow', 'green']}, 'NDVI Median');

/**
 * 4. COMBINE AND EXPORT TO GOOGLE DRIVE
 * This combines all bands into a single multiband GeoTIFF file.
 */
var completeDataset = ee.Image.cat([temp, precip, soilMoisture, elevation, ndvi]);

Export.image.toDrive({
  image: completeDataset,
  description: 'Environmental_Variables_Export',
  folder: 'GEE_Exports',
  scale: 30, // Resolution in meters (Adjust higher if exporting massive areas to avoid errors)
  region: studyArea,
  maxPixels: 1e13,
  fileFormat: 'GeoTIFF'
});

print("Layers compiled! Head to the 'Tasks' tab on the right and click 'Run' to begin the download.");



Thank you for reading.

Thursday, October 15, 2026

Designing Graphical Abstract for a research paper titled: Economic Valuation of Regional Agricultural Outputs: Grains, Fruits, and Fisheries in Nigeria

 This post is about designing a graphical abstract for an assumed paper titled "Economic Valuation of Regional Agricultural Outputs: Grains, Fruits, and Fisheries in Nigeria". The graphical assests focus on the core takeways of the paper which are: Nigeria, Grains, Fruits, and Fisheries.

These takeaways will serve as inputs, methodologically linked by directional arrows to illustrate how the study processes them into a final output. This is what 'graphical abstract' is all about.

The video guide is available on this youtube link. At the end, you should be able to transform this hand sketch idea into the publication-ready graphical abstract below using Inkscape software.







Thank you.

Monday, October 5, 2026

AI Agent (by TerraLab) in QGIS to fetch security installations

Mapping Abuja’s Security Infrastructure: How to Fetch Point Layers using TerraLab's AI Agent for QGIS

Geospatial data extraction has historically required jumping between specialized data web portals, building complex Overpass API queries, or manually digitizing locations. However, with the emergence of AI agents built directly into GIS environments, extracting specific spatial data is now as simple as writing a chat message.

In this guide, we will walk through using the AI Agent by TerraLab inside QGIS to automatically pull a comprehensive point layer of security installations within the Abuja Municipal Area Council (AMAC), Nigeria. We will cover police stations, military cantonments/barracks, and the Nigeria Security and Civil Defence Corps (NSCDC) offices.

I decided to try the AI Agent in QGIS, I installed the AI agent by TerraLab via the plugin manager, it was a great expereice to say the least. It literally completed a task for me in way less minutes than I would have done it manually. Here are the details of what I tasked it to do;-

Task/Prompt: I need point layer for all the security agents offices in Abuja Municipal Area Council (AMAC) including Police stations, Millitary cantonments/baracks and Nigeria Security & Civil Defence Corps.

Result: As seen below, it successfully retrieved 53 points for the result. Although, not all were security infrastructures I expected, so I did some manual verification and cleaning.


How to Install and Initialize the AI Agent

Before prompting the agent, ensure you have the plugin installed and ready in your workspace.

  1. In QGIS, navigate to the top menu and select Plugins > Manage and Install Plugins.
  2. Search for AI Agent by TerraLab and click Install Plugin.
  3. Once installed, open the agent interface panel using the keyboard shortcut Ctrl + Alt + A (or click the TerraLab icon in your toolbar).
  4. Sign in to your account to activate your monthly free message allowance.


After you are signed in, enter the prompt and once you hit submit, the AI Agent creates an execution plan which you can monitor live in the side panel:

  1. Boundary Retrieval: The agent queries global administrative databases to find the official polygon layer for AMAC.
  2. Data Extraction: It simultaneously queries regional open datasets using tags like amenity=police, military=barracks, and generic security/government office infrastructure filters tailored to Nigeria's public safety sectors.
  3. Reprojection & Layer Creation:

The data is transformed into your project’s Coordinate Reference System (CRS) and compiled into a dedicated point feature layer.

  1. Symbology Application: Instead of generic circles, the agent can apply categorized styling, assigning separate colors or icons for Police, Military, and NSCDC sites if that was stated in the initial prompt.

One of the most powerful aspects of the TerraLab AI Agent is its built-in safety net. If the agent misinterprets a layout or grabs points outside your target area, you don't have to manually delete elements. You can use the one-click Undo checkpoint feature in the panel to revert the changes and refine your prompt.

Once you are satisfied with the layer, you can right-click the newly generated layer in your QGIS Layers Panel and select Export > Save Features As... to save the clean dataset permanently as a GeoPackage or Shapefile for your local security intelligence audits.

By leveraging the AI Agent by TerraLab, what used to be a tedious multi-step data mining workflow is reduced to a single conversational task. Whether you are mapping critical infrastructure for urban planning or conducting risk assessments in Nigeria's capital, AI-driven GIS tools ensure your time is spent analyzing data rather than hunting for it.

TerraLab provides three major AI-powered plugins for QGIS: AI Agent (for automating GIS workflows via text chat), AI Segmentation (for extracting vector polygons from imagery), and AI Edit (for visualizing spatial planning and changing pixels with text prompts).

Happy AIing!