0

Tried to export transition classes for a region of interest. I cant export image to drive for my selected feature collection. Getting an error after running for a while,"A region must be a GeoJSON Polygon or LinearRing. Got: 'MultiPolygon'. Here is the code below- how can i export image for a region that i selected from my shapefiles?

var reg = ee.FeatureCollection('users/karmakersourav/shape')
    .filter(ee.Filter.eq('NAME_1', 'Chittagong'));

Map.addLayer(reg);

var gsw = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');    
var transition = gsw.select('transition');    
Map.addLayer({      
eeObject: transition,
  name: 'Transition classes (2010-2015)',    
});

Export.image.toDrive({
 image: gsw,
 description: 'imageToCOGeoTiffExample',
 scale: 30,
 region: reg,
 fileFormat: 'GeoTIFF',
 maxPixels: 1e12,
 formatOptions: {
    cloudOptimized: true
  }
});
  • 1
    It feels like some of your region geometries is a multipolygon. Error tells that you can't use multipolygon so you must do something for it. Split it into single part polygons or use for example the envelope of the geometry instead. – user30184 Feb 13 at 20:44
  • Your feature collection is not public – Kuik Feb 14 at 11:02
0

What you probably want to do is only export that part of the image which falls inside your region of interest, a featureCollection consisting of one feature which geometry is a multipolygon.

For that you'd best clip the image on your multipolygon, and then export that part of the image which falls inside the bounding rectangle of those polygons.

To get the bounding rectangle of your area of interest:

var reg = ee.FeatureCollection('users/karmakersourav/shape')
    .filter(ee.Filter.eq('NAME_1', 'Chittagong'));
// make one feature of the feature collection (as it only consists of 1 feature)
var reg = ee.Feature(reg.first());
// get the bounding rectangle of the feature collection
var boundingRectangle = reg.bounds();

Then clip your image on the geometry you have defined as input:

// load the image
var gsw = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');    
var transition = gsw.select('transition');    
// clip the image to the region of interest to only export that part
var clipped = transition.clip(reg);

And then export the image using:

Export.image.toDrive({
image: clipped,
description: 'imageToCOGeoTiffExample',
scale: 30,
region: boundingRectangle,
fileFormat: 'GeoTIFF',
maxPixels: 1e12,
formatOptions: {
    cloudOptimized: true
  },
skipEmptyTiles: true
});

Link script

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.