IMD Temperature Data Interpolation in Google Earth Engine
Pulakesh Pradhan
PhD Scholar, MPhil, UGC-SRF (Focus Area: Climate and Agriculture || Rural Geography)
To perform spatial interpolation using kriging for temperature data in Google Earth Engine (GEE), let’s break down this script, step by step. This approach is powerful for environmental monitoring, as it allows estimation of values at unmeasured locations using data from known points.
Step 1: Importing Data and Calculating the Mean Temperature
We start with a Collection of temperature images, from which we want to extract temperature data (b1 band) over a specified roi (region of interest). The mean() function calculates the average temperature at each pixel location over the collection’s time period.
var temperature = Collection.select('b1').mean().clip(roi);
This line:
Step 2: Visualizing the Mean Temperature
We define visualization parameters, specifying the color palette, data range, and coordinate reference system (CRS).
var palettes = require('users/gena/packages:palettes');
var visParam = {
crs: 'EPSG:4326',
min: 31,
max: 34,
palette: palettes.kovesi.rainbow_bgyr_35_85_c72[7]
};
Map.addLayer(temperature, visParam, 'Mean Temperature');
Here:
Step 3: Defining a Grid of Points for Kriging
Kriging requires points with known values as input. We create a structured grid of points within our study area using a specified longitude and latitude range.
var x = ee.List.sequence(80, 90.0, 0.25); // Longitude range and step
var y = ee.List.sequence(16, 25, 0.25); // Latitude range and step
var gridPoints = ee.FeatureCollection(x.map(function(xcor) {
return y.map(function(ycor) {
return ee.Feature(ee.Geometry.Point([xcor, ycor]));
});
}).flatten());
Map.addLayer(gridPoints, {color: 'black'}, 'Grid Points');
This generates a grid covering the region with points spaced at 0.25 degrees and displays them on the map in black.
Step 4: Sampling Temperature at Each Grid Point
Using reduceRegions, we sample the mean temperature at each grid point from the temperature layer. This operation reduces data over regions (here, points) and assigns each point a mean temperature value.
var samples = temperature.reduceRegions({
collection: gridPoints,
reducer: ee.Reducer.mean(),
scale: 1000,
crs: 'EPSG:4674'
});
领英推荐
To finalize, we set the temperature value to a property called 'temp' and filter out points without valid temperature data.
samples = samples.map(function(feature) {
var temp = feature.get('mean');
return feature.set('temp', temp).setGeometry(feature.geometry());
}).filter(ee.Filter.notNull(['temp']));
Map.addLayer(samples, {color: 'blue'}, 'Sampled Grid Points with Temperature');
Step 5: Applying Kriging Interpolation
Now that we have temperature data at each grid point, we apply kriging, a geostatistical method that predicts values for unsampled locations based on the spatial autocorrelation structure of the data.
var kriging = samples.kriging({
propertyName: 'temp',
shape: 'gaussian', // Shape of the variogram model
range: 100000, // Maximum range of spatial correlation (in meters)
sill: 1.0, // Variogram sill (variance of the variable)
nugget: 0.1, // Variogram nugget (measurement error or small-scale variation)
maxDistance: 100000, // Maximum distance for neighborhood search
reducer: 'mean'
});
Key parameters in kriging:
Step 6: Visualizing Kriged Temperature Data
The kriged output is clipped to roi and visualized using the same color palette as before for consistent interpretation.
Map.addLayer(kriging.clip(roi), visParam, 'Temperature - Kriging');
Final Output
This script generates a continuous temperature surface over the study region, using kriging to predict temperature across areas where we don’t have direct measurements. This is especially useful for environmental applications where data is sparse, allowing for temperature pattern analysis and supporting climate-related studies.
Summary
This approach is practical for any region with sparse measurement points and is applicable to other geospatial interpolation needs by simply adjusting parameters.
?? More insights & projects: pulakeshpradhan.github.io