0

How I can export to drive a clipped part of a WorldPop image, I'm using the following code but crush ....

// clip fun
var clipToCol = function(image){
  return image.clip(export_geometry_2);
};


var dataset = ee.ImageCollection("WorldPop/GP/100m/pop").map(clipToCol)
                .filterDate('2017');
var population = dataset.select('population');
var populationVis = {
  min: 0.0,
  max: 50.0,
  palette: ['24126c', '1fff4f', 'd4ff50'],
};
Map.setCenter(113.643, 34.769, 7);
Map.addLayer(population, populationVis, 'Population');

Export.image.toDrive({
image: dataset.select('population'),
description: 'worldPop',
scale: 100,
region: export_geometry_2
})

1 Answer 1

1

Please see below a reproducible example. The example you have given uses variables that are not defined.

// Define ply geometry 
var geometry = ee.Geometry.Polygon([[113.29693066406253,32.978167214883634],
                                   [119.66900097656253,32.978167214883634],
                                   [119.66900097656253,36.20607892441336],
                                   [113.29693066406253,36.20607892441336],
                                   [113.29693066406253,32.978167214883634]])
// Define clip tool 
var clipToCol = function(image){
  return image.clip(geometry);
};

// Define WorldPop & clip using function 
var dataset = ee.ImageCollection("WorldPop/GP/100m/pop").map(clipToCol)
                .filterDate('2017');

// Mosaic dataset
var mosaic = dataset.select('population').mosaic();

// Define colour scheme 
var populationVis = {
  min: 0.0,
  max: 50.0,
  palette: ['24126c', '1fff4f', 'd4ff50'],
};

// Set map centre
Map.setCenter(113.643, 34.769, 7);

// Add layer to map 
Map.addLayer(mosaic , populationVis, 'Population');

// Export to GDrive
Export.image.toDrive({
image: mosaic,
description: 'worldPop',
scale: 100,
region: geometry
})

Simply follow this link to run this script in Google Earth Engine

After running this script, the Tasks tab will be highlighted. You must click on this and the task to define where you would like to store this export in Google Drive / other file storage system.

Please accept the answer if this fullfils your answer.

2
  • This task fails, as you try to export an imageCollection. Convert it to an image using a reducer or mosaic function (e.g. dataset.select('population').mosaic())
    – Kuik
    Feb 20, 2020 at 19:09
  • 1
    Your're correct, the image does not export into Drive. I have updated my answer by adding the var mosaic.
    – tastatham
    Feb 20, 2020 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.