I want to Visualize a Landcover Classification

I have different success with seemingly identical Lists.

List 1: Pallette Parameters inside the Code like:

var landcoverPalette1 = [ 'E6004D', //Artificial surfaces > Urban fabric > Continuous urban fabric 'FF0000' //Artificial surfaces > Urban fabric > Discontinuous urban fabric ]

List2: Palette Obtained via Code

var landcoverPalette = ee.List(lc2012.get('landcover_class_palette'))

List1 and List2 are identical withing the print() statement(see Code), but List2 generates an Error

2012: Layer error: Image.visualize: Expected a string or list of strings for field 'palette'.

Code without Error

Code with Error


You are mixing client-side and server-side objects, see here.

You will need to make the visualization a server-side object (namely, a dictionary):

var landcoverPalette = ee.List(lc2012.get('landcover_class_palette'))

var landcoverVisualization= ee.Dictionary({palette: landcoverPalette, min: 0, max: 44, format: 'png'});

full link

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.