An error occurred in raster to vector conversion:

Layer 1: Layer error: ImageCollection.mosaic: Invalid type. Expected type: Image. Actual type: FeatureCollection.

Why is the Map function trying to mosaic an image collection when I have a feature collection that is also a valid input to Map.

My code link is: https://code.earthengine.google.com/f14646de49f536d7ed4b4e0d5a9ccb21

  var elevation=SRTM;
  var sorted = L8.filter(ee.Filter.eq('WRS_PATH', 147))
  .filter(ee.Filter.eq('WRS_ROW', 38))
 .filterMetadata('CLOUD_COVER', 'less_than', 10)

var ndwi1 = sorted.map(
 function(img) {

   var ndwi = img.normalizedDifference(['B3','B5']);
   var slop = ee.Terrain.slope(elevation);
   var evi1 = ndwi.expression('(thr>0.25) && (slp<20)? 1 : 0' , 

      {  'thr' : ndwi,  'slp' : slop   });

   var evi = evi1.clip(table)

   var vectors = evi.addBands(evi)
      geometry: table,
      crs: evi.projection(),
      scale: 30,
      geometryType: 'polygon',
      reducer: ee.Reducer.mean(),
      maxPixels: 1e8

 return vectors;


1 Answer 1


I can't run the code because the table asset is not shared. However, I think you will need to cast ndwi1 as an ee.FeatureCollection() and then flatten() it. Mapping over the sorted image collection returns a collection of feature collections, which cannot be added as a Map layer. Replace your last two lines with this:

var ndwiFc = ee.FeatureCollection(ndwi1).flatten()

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.