Google Earth Engine Tutorial: Clip and Extract Population Data
Credit: Youtube Channel “Terra Spatial, Tutorial on clipping global population data to specific regions and extracting statistical information.”
You can see all the tutorials from here: Techgeo Academy.
Step 1: Load Population Data
Start by loading a global population dataset from the Google Earth Engine (GEE) catalog. A commonly used dataset is the Global Population Density Layer (GPD). Hereβs an example code snippet:
var population = ee.Image('JRC/GHSL/P2016/POP_GPW4_GSAD30_V1');
Step 2: Define Region of Interest (ROI)
Create or load a geometry to define the area you want to clip. For example, using a built-in dataset like the WorldBorder:
var roi = ee.FeatureCollection('FAO/GAUL/WEEKLY').filter(ee.Filter.eq('ADM0_NAME', 'Kenya'));
Step 3: Clip the Population Data
Use the clip()
method to restrict the population data to your ROI:
var clippedPopulation = population.clip(roi);
Step 4: Extract Summary Statistics
Calculate statistics such as mean, max, or total population within the clipped region:
var stats = clippedPopulation.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: roi.geometry(),
scale: 30,
maxPixels: 1e9
});
print(stats.get('population'));
Step 5: Export Clipped Data
Export the clipped image as a GeoTIFF or CSV file for further analysis:
Export.image.toDrive({
image: clippedPopulation,
description: 'ClippedPopulation',
fileNamePrefix: 'kenya_population',
folder: 'GEE_Exports',
scale: 30,
crs: 'EPSG:4326',
region: roi.geometry()
});
FAQ
- What population datasets are available in GEE? GEE provides datasets like JRC/GHSL/P2016/POP_GPW4_GSAD30_V1, USGS/GFSAD/2019, and others. Check the GEE Data Catalog for details.
- How do I handle large regions? Use the
region
parameter inreduceRegion
or split the region into smaller tiles for processing. - Why is the clipped area showing null values? Ensure the ROI geometry is valid and properly defined. Check for projection mismatches using
crs
orprojection
parameters. - Can I export data to CSV instead of GeoTIFF? Yes, use
Export.table.toDrive()
withreduceRegion
results to export as CSV. - What if I encounter access errors? Verify your GEE account has the necessary permissions and that the dataset is publicly accessible.