1

I have a classified geotiff raster that has two classes 0 and 1. I changed its type to int and imported it from my computer to GEE using upload a new asset and I changed its var name to image and I wrote this lines:

Map.addLayer(image);
    
var classes = image.reduceToVectors({
      reducer: ee.Reducer.countEvery(), 
      scale: 20,
      maxPixels: 1e10
});
var result = ee.FeatureCollection(classes);
Map.addLayer(result);
    
// Export the results to Drive
Export.image.toDrive({
      image: result,
      description: 'SGenova_int',
      scale: 20,
      crs: 'EPSG:4326', 
      maxPixels: 1e10
});

I got this error while exporting:

Error: Image.setDefaultProjection, argument 'image': Invalid type. Expected type: Image. Actual type: FeatureCollection.

1

I created a fictional image with two classes 0 and 1. As you, I changed its type to int and imported it from my computer to GEE using upload a new asset and I changed its var name to image. However, as result is a feature collection instead of image, I imported it as shapefile to Drive as follows:

var image = ee.Image("users/joseguerreroa/raster_files_utah/polygon8_raster")
  .toInt();

Map.addLayer(image);
Map.centerObject(image);

var classes = image.reduceToVectors({
  reducer: ee.Reducer.countEvery(), 
  scale: 20,
  maxPixels: 1e10
});

var result = ee.FeatureCollection(classes);

Map.addLayer(result);

// Export the FeatureCollection to a SHP file.
Export.table.toDrive({
  collection: result,
  folder: 'GEE_folder',
  description:'SGenova_int',
  fileFormat: 'SHP'
});

After running above code in GEE code editor and its associated task, I got successful result of following image:

enter image description here

2
  • Thansk so much @xunilk. It worked
    – Paris
    Apr 1 at 10:38
  • You're welcome.
    – xunilk
    Apr 2 at 0:59

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .