1

I have loaded SRTM (30m resolution) DEM data through Google Earth Engine and have determined the slope for the entire country of Peru. When I export the image out into Google Drive, I get the following error message- "Export region contains no valid (un-masked) pixels".

How can I export out slope rasters (tifs mostly) via GEE for entire countries? My code is available here.

https://code.earthengine.google.com/2f490881ca64a744041c0cc702a24a95

I have also changed the max number of pixels that can be exported, but I still hit the same problem.

2

Here is an example of exporting a raster of slopes for a country:

// Load the SRTM image.
var srtm = ee.Image('USGS/SRTMGL1_003');

// Calculate slope.
var slope = ee.Terrain.slope(srtm);

// Load a country border as a region of interest (roi).
var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017');
var roi = countries.filterMetadata('country_na', 'equals', 'Peru');

// Clip the image to the region of interest.
slope = slope.clip(roi);

// Displaying slope for the region of interest.
var visualization_params = {min: 0, max: 45, palette:'white,red'};
Map.centerObject(roi);
Map.addLayer(slope, visualization_params, "slope");

// Export the image, specifying scale and region.
Export.image.toDrive({
  image: slope.visualize(visualization_params),
  region: roi,
  description: 'imageToDriveExample',
  scale: 30,
  maxPixels: 1e12
});

Note that:

  • If you want to export slope values, rather than a RGB visualization, remove the .visualize() method from the export parameters.
  • For large regions (such as this) the export will be broken up into a set of tiled GeoTIFF files.
  • Thank you! It worked. But unfortunately, the values downloaded seem to not make sense. Slope values (from DEM) are to range between 0-90, after projection to a system with a linear unit. I downloaded loaded the slope tiles from GEE and projected it to a UTm system, using bilinear resampling since slope is continuous. The values range from -665. to 6741, which does not make sense for slope. Any suggestions what this means? – tg110 Apr 12 '18 at 17:55
  • What code or other program did you use to go "from GEE and projected it to a UTm system"? – Tyler Erickson Apr 12 '18 at 21:22
0

For me the exported worked without any errors after I changed your export command and set the region parameter.

Export.image.toDrive({
  image: slopePeru,
  region: justPeru,
  description: 'slopePeru',
  scale: 30,
  maxPixels: 1e12
});
0

For Tyler Erickson answer to work the region parameter of the export command must be changed to:

Export.image.toDrive({
  image: slope.visualize(visualization_params),
  region: roi.geometry().bounds(),
  description: 'imageToDriveExample',
  scale: 30,
  maxPixels: 1e12
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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