2

I have been trying to download 4 bands of the Hansen forest change data from GEE, and need the rasters to span the entire world. I have been using the following code to do so:

var myStringArrayGFW = ['treecover2000','loss','gain','lossyear'];
var dataset_name = "UMD/hansen/global_forest_change_2020_v1_8"; 
var dataset = ee.Image(dataset_name);
var myStringArray = myStringArrayGFW;
    
myStringArray.forEach(function(s) {
  var name = dataset_name.replace(new RegExp('/', 'gi'),'-');
  var data = dataset.select(s); 
  Export.image.toDrive({
    image: data,
    description: name+"-"+s, 
    scale:5000, //5x5km
    maxPixels: 1e13,
  });
  });  

Running this seems to work, as I can then save the files to my google drive, but the tifs I get are only a fraction of the size I need them to be (see picture below).This is what I get for example, a 125ko file.

How would I go about fixing my code such that it downloads the entire rasters?

2
  • Welcome to GIS SE. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question. Providing a bullet list of questions is a quick way to Question closure.
    – Vince
    Mar 27, 2022 at 18:13
  • Thanks @Vince, updated my question to reflect this.
    – Alex
    Mar 28, 2022 at 13:52

1 Answer 1

2

Specify a region spanning the whole world (easiest way is as a non-geodesic polygon that doesn't touch the poles); you're just getting whatever the code editor happens to be looking at when you start the Export.

Export.image.toDrive({
    image: data,
    region: ee.Geometry.Polygon([
        -180, 88, 
           0, 88, 
         180, 88, 
         180, -60, 
           0, -60,
        -180, -60], null, false]),
    ...
1
  • Ah that does it, great thank you!
    – Alex
    Mar 28, 2022 at 18:39

Your Answer

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

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