0

I am trying to visualize the USDA soil map based on the taxonomy great groups. On the info page of the dataset, it seems as if this could be found in the properties. More specifically in grtgroup Class Table: color.

My approach so far did not color it properly.

var area =     ee.Geometry.Polygon(
        [[[6.86, 50.75],  [6.86, 50.60],[7.30, 50.60],  [7.30, 50.75]]], null, false);
var soil =ee.Image("OpenLandMap/SOL/SOL_GRTGROUP_USDA-SOILTAX_C/v01")
Map.addLayer(soil.clip(area), {}, 'soil');
Map.centerObject(area,11);
print(soil,'soil')

var names = soil.get('visualization_0_name');
print(names);
var band = soil.get('visualization_0_bands');
print(band);

I already checked the answer to this question and it seems like it is possible to slice out the palette from the properties in the MODIS image.

Is this also possible with the soil dataset and how can I read out the palette values and visualize the image?

1 Answer 1

1

You can start by defining your colors as a dictionary, mapping value to color. Then turn it into an array of colors, where the index is the value, filling non-existing value with some default color. Finally, turn this into a palette string. Remember to set your min and max value too.

// *Note*: this code block is all client-side JavaScript - no GEE objects or methods.

var colors = {
  0: 'FFFFFF', 
  1: 'ADFF2D', 
  2: 'ADFF22', 
  4: 'A5FF2F', 
  6: '87FF37',
  // ...
}

var maxValue = Math.max.apply(null, Object.keys(colors))
var array = Array.apply(null, Array(maxValue + 1))
  .map(function() { return '000000' })

Object.keys(colors).forEach(function (i) {
  array[i] = colors[i]
})

var palette = array.join(',')
var visParams = {min: 0, max: maxValue, palette: palette}

https://code.earthengine.google.com/dfab15f56973e2da30544bc53835edcb

2
  • How did you obtain the color information? Did you just copy it from the data catalog page or how did you get it?
    – jreith
    Commented Jan 22, 2020 at 13:43
  • Yes - copy and paste from your link Commented Jan 22, 2020 at 14:25

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.