I need to reclassify slope raster (val: 0-90) to 9 classes (1-9). I used this code but the output raster cannot be displayed. What did I do wrong?
// Add features
var sumatera = ee.FeatureCollection("users/putraditama/sumatera");
// Add raster
var elev = ee.Image("USGS/SRTMGL1_003")
// Clip elev to Sumatera boundary
var elevsmrt = elev.clip(sumatera);
// Get slope
var slopesmrt = ee.Terrain.slope(elevsmrt);
// Remap values
var slopereclass = slopesmrt
.remap([0-10,11-20,21-30,31-40,41-50,51-60,61-70,71-80,81-90],
[1,2,3,4,5,6,7,8,9]);
// Display the result.
Map.addLayer(slopesmrt, {min: 0, max :90, palette: ['black', 'white']},'slope');
Map.addLayer(slopereclass, {min: 1, max :9}, 'slopereclass');
Best Answer
The accepted solution addresses the very specific case at hand, and while admirably clever (kudos for that), does not answer the question, which is "How to reclass ranges in GEE".
A more general case of reclassification of ranges into user specific classes would be with conditional assignment using
where
...and so on. Clearly, more to write but now I could specify any class range I want.