1

I want to export clip image with the population data. But when I run the export file in the TASK menu, I get this error:

Error: Image.clipToBoundsAndScale, argument 'input': Invalid type. Expected type: Image. Actual type: ImageCollection. (Error code: 3)

Images are not exported. Can you help me about this issue?

var shp = ee.FeatureCollection(antalya)

Map.centerObject(antalya);

Map.addLayer(shp,{},'bolge')

var dataset = ee.ImageCollection('JRC/GHSL/P2016/POP_GPW_GLOBE_V1')
                  .filterBounds(antalya)
                  .filter(ee.Filter.date('2015-01-01', '2015-12-31'))
                  ;
           
  var antalyanufus = dataset.map(function(img){return img.clip(antalya)})

 var populationCount = dataset.select('population_count');
var populationCountVis = {
  min: 0.0,
  max: 200.0,
  palette: ['060606', '337663', '337663', 'ffffff'],
};

Map.addLayer(populationCount, populationCountVis, 'Population Count');

var antalyanufusVis = {
  min: 0.0,
  max: 200.0,
  palette: ['060606', '337663', '337663', 'ffffff'],
};

var antalyanufusVisrenkli = {
  min: 0.0,
  max: 200.0,
  palette: ['ffffe4','5a76ff','0c13ff','001189'],
};

Map.addLayer(antalyanufus,antalyanufusVisrenkli,'Antalya nufus');


var panel = ui.Panel({
  style: {
    position: 'bottom-left',
    padding: '5px;'
  }
})

var title = ui.Label({
  value: 'Nufüs Yoğunluğu',
  style: {
    fontSize: '14px',
    fontWeight: 'bold',
    margin: '0px;'
  }
})

panel.add(title)

var color = ["ffffe4","5a76ff","0c13ff","001189"]

var lc_class = ['seyrek','az yoğun','yoğun','Çok yoğun']

var list_legend = function(color, description) {
  
  var c = ui.Label({
    style: {
      backgroundColor: color,
      padding: '10px',
      margin: '4px'
    }
  })
  
  var ds = ui.Label({
    value: description,
    style: {
      margin: '5px'
    }
  })
  
  return ui.Panel({
    widgets: [c, ds],
    layout: ui.Panel.Layout.Flow('horizontal')
  })
}

for(var a = 0; a < 4; a++){
  panel.add(list_legend(color[a], lc_class[a]))
}

Map.add(panel)


// Export to GDrive
Export.image.toDrive({
image: dataset.select('antalyanufus'),
description: 'nufus',
scale: 100,
region: antalya
})
1
  • 1
    "but I can't" doesn't give us enough information. Please edit your question to include any error message (as text, not screenshot), or explain exactly what happens when you run the script or click run on the task.
    – user2856
    Commented Apr 22, 2022 at 13:01

1 Answer 1

1

Even though you've filtered the collection down to 1 year, it's still a collection. You need to get an image out of it. You can do that with first

var dataset = ee.ImageCollection('JRC/GHSL/P2016/POP_GPW_GLOBE_V1')
                  .filterBounds(antalya)
                  .filter(ee.Filter.date('2015-01-01', '2015-12-31'))
                  .first()

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.