Masking using two sliders on Google Earth EngineCharting two FeatureCollections in Google Earth...

What Marvel character has this 'W' symbol?

Just how much information should you share with a former client?

Was Donald Trump at ground zero helping out on 9-11?

Is it possible to tell if a child will turn into a Hag?

How can a class have multiple methods without breaking the single responsibility principle

Can I attune a Circlet of Human Perfection to my animated skeletons to allow them to blend in and speak?

How do I make my photos have more impact?

Word for soundtrack music which is part of the action of the movie

How can I solve this sudoku?

Rampant sharing of authorship among colleagues in the name of "collaboration". Is not taking part in it a death knell for a future in academia?

Is it okay for me to decline a project on ethical grounds?

Typesetting numbers above, below, left, and right of a symbol

Embedded C - Most elegant way to insert a delay

How can flights operated by the same company have such different prices when marketed by another?

How can a circuit not have a neutral?

What is my clock telling me to do?

Easy way to get process from window

How can Paypal know my card is being used in another account?

Bouncing map back into its bounds, after user dragged it out

Antonym of "Megalomania"

Can machine learning learn a function like finding maximum from a list?

Why are we moving in circles with a tandem kayak?

Using Python in a Bash Script

How do you deal with characters with multiple races?



Masking using two sliders on Google Earth Engine


Charting two FeatureCollections in Google Earth Engine?Landsat 8 cloud/cloud shadow/snow masking in Google Earth EngineGoogle Earth Engine - Map.addLayerCreating opacity mask in Google Earth Engine?How I get the masking area data and export data in Google Earth Engine?Sentinel 3 Cloud Masking in Google Earth EngineGoogle Earth Engine Mask applicationGoogle Earth Engine: Masking land out of Sentinel-3 imageryUploading polygons and masking pixels inside the polygons using Google Earth Engine?Adding slider for dynamic index threshold on Google Earth Engine?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I am trying to apply a mask based on two conditions (elevation and MNDWI), however, I don't find a way to integrate the two conditions using sliders, which would update the map when any of the sliders are used.
I have created the sliders and variables however they work independently, applying only one of the two thresholds when a slider is used.
At the end of the code, the variable "desired" describes the desired output.



    var start = '2014-09-15';
var end = '2014-12-30';
var year = '2014_wet';

var ndwicollection = ee.ImageCollection('LANDSAT/LC8_L1T_8DAY_NDWI')
.filterDate(start, end).first();
print ('ndwicollection', ndwicollection);

var srtm = ee.Image('USGS/SRTMGL1_003');

var mndwiParams = {min: -1, max: 1, palette: ['green', 'yellow', 'blue']};

// threshhold


// Create a label and slider for MNDWI.
var label = ui.Label('MNDWI Threshold');

var slider = ui.Slider({
min:-1,
max: 1,
step: 0.01,
style: {stretch: 'horizontal', width:'500px' },
onChange: (function(value) {
Map.layers().reset();
var ndwi_collection_mask = ndwicollection.updateMask
(ndwicollection.gte(value));
Map.addLayer(ndwi_collection_mask, {palette: 'blue'}, 'MNDWI threshold '+String(value));
return ndwi_collection_mask;})
});
slider.setValue(0.0); // Set a default value.

// Create a label and slider for Elevation.
var label1 = ui.Label('Elevation');
var slider1 = ui.Slider({
min:0,
max: 3000,
step: 1,
style: {stretch: 'horizontal', width:'500px' },
onChange: (function(value1) {
Map.layers().reset();
var srtmmask = srtm.updateMask(srtm.lte(value1));
Map.addLayer(srtmmask, {palette: 'blue'}, 'MNDWI threshold '+String(value1));
return srtmmask;})
});
slider1.setValue(0); // Set a default value.


// Create a panel that contains both the slider and the label.
var panel = ui.Panel({
widgets: [label, slider, label1,slider1],
layout: ui.Panel.Layout.flow('vertical'),
style: {position: 'bottom-right',width: '520px'
}
});

// Add the panel to the map.
Map.add(panel);

//// to replace with sliders
var desired = srtm.updateMask(srtm.lte(100)).and(ndwicollection.updateMask
(ndwicollection.gte(0)));
Map.addLayer(desired, {palette: 'blue'});









share|improve this question

































    1















    I am trying to apply a mask based on two conditions (elevation and MNDWI), however, I don't find a way to integrate the two conditions using sliders, which would update the map when any of the sliders are used.
    I have created the sliders and variables however they work independently, applying only one of the two thresholds when a slider is used.
    At the end of the code, the variable "desired" describes the desired output.



        var start = '2014-09-15';
    var end = '2014-12-30';
    var year = '2014_wet';

    var ndwicollection = ee.ImageCollection('LANDSAT/LC8_L1T_8DAY_NDWI')
    .filterDate(start, end).first();
    print ('ndwicollection', ndwicollection);

    var srtm = ee.Image('USGS/SRTMGL1_003');

    var mndwiParams = {min: -1, max: 1, palette: ['green', 'yellow', 'blue']};

    // threshhold


    // Create a label and slider for MNDWI.
    var label = ui.Label('MNDWI Threshold');

    var slider = ui.Slider({
    min:-1,
    max: 1,
    step: 0.01,
    style: {stretch: 'horizontal', width:'500px' },
    onChange: (function(value) {
    Map.layers().reset();
    var ndwi_collection_mask = ndwicollection.updateMask
    (ndwicollection.gte(value));
    Map.addLayer(ndwi_collection_mask, {palette: 'blue'}, 'MNDWI threshold '+String(value));
    return ndwi_collection_mask;})
    });
    slider.setValue(0.0); // Set a default value.

    // Create a label and slider for Elevation.
    var label1 = ui.Label('Elevation');
    var slider1 = ui.Slider({
    min:0,
    max: 3000,
    step: 1,
    style: {stretch: 'horizontal', width:'500px' },
    onChange: (function(value1) {
    Map.layers().reset();
    var srtmmask = srtm.updateMask(srtm.lte(value1));
    Map.addLayer(srtmmask, {palette: 'blue'}, 'MNDWI threshold '+String(value1));
    return srtmmask;})
    });
    slider1.setValue(0); // Set a default value.


    // Create a panel that contains both the slider and the label.
    var panel = ui.Panel({
    widgets: [label, slider, label1,slider1],
    layout: ui.Panel.Layout.flow('vertical'),
    style: {position: 'bottom-right',width: '520px'
    }
    });

    // Add the panel to the map.
    Map.add(panel);

    //// to replace with sliders
    var desired = srtm.updateMask(srtm.lte(100)).and(ndwicollection.updateMask
    (ndwicollection.gte(0)));
    Map.addLayer(desired, {palette: 'blue'});









    share|improve this question





























      1












      1








      1








      I am trying to apply a mask based on two conditions (elevation and MNDWI), however, I don't find a way to integrate the two conditions using sliders, which would update the map when any of the sliders are used.
      I have created the sliders and variables however they work independently, applying only one of the two thresholds when a slider is used.
      At the end of the code, the variable "desired" describes the desired output.



          var start = '2014-09-15';
      var end = '2014-12-30';
      var year = '2014_wet';

      var ndwicollection = ee.ImageCollection('LANDSAT/LC8_L1T_8DAY_NDWI')
      .filterDate(start, end).first();
      print ('ndwicollection', ndwicollection);

      var srtm = ee.Image('USGS/SRTMGL1_003');

      var mndwiParams = {min: -1, max: 1, palette: ['green', 'yellow', 'blue']};

      // threshhold


      // Create a label and slider for MNDWI.
      var label = ui.Label('MNDWI Threshold');

      var slider = ui.Slider({
      min:-1,
      max: 1,
      step: 0.01,
      style: {stretch: 'horizontal', width:'500px' },
      onChange: (function(value) {
      Map.layers().reset();
      var ndwi_collection_mask = ndwicollection.updateMask
      (ndwicollection.gte(value));
      Map.addLayer(ndwi_collection_mask, {palette: 'blue'}, 'MNDWI threshold '+String(value));
      return ndwi_collection_mask;})
      });
      slider.setValue(0.0); // Set a default value.

      // Create a label and slider for Elevation.
      var label1 = ui.Label('Elevation');
      var slider1 = ui.Slider({
      min:0,
      max: 3000,
      step: 1,
      style: {stretch: 'horizontal', width:'500px' },
      onChange: (function(value1) {
      Map.layers().reset();
      var srtmmask = srtm.updateMask(srtm.lte(value1));
      Map.addLayer(srtmmask, {palette: 'blue'}, 'MNDWI threshold '+String(value1));
      return srtmmask;})
      });
      slider1.setValue(0); // Set a default value.


      // Create a panel that contains both the slider and the label.
      var panel = ui.Panel({
      widgets: [label, slider, label1,slider1],
      layout: ui.Panel.Layout.flow('vertical'),
      style: {position: 'bottom-right',width: '520px'
      }
      });

      // Add the panel to the map.
      Map.add(panel);

      //// to replace with sliders
      var desired = srtm.updateMask(srtm.lte(100)).and(ndwicollection.updateMask
      (ndwicollection.gte(0)));
      Map.addLayer(desired, {palette: 'blue'});









      share|improve this question
















      I am trying to apply a mask based on two conditions (elevation and MNDWI), however, I don't find a way to integrate the two conditions using sliders, which would update the map when any of the sliders are used.
      I have created the sliders and variables however they work independently, applying only one of the two thresholds when a slider is used.
      At the end of the code, the variable "desired" describes the desired output.



          var start = '2014-09-15';
      var end = '2014-12-30';
      var year = '2014_wet';

      var ndwicollection = ee.ImageCollection('LANDSAT/LC8_L1T_8DAY_NDWI')
      .filterDate(start, end).first();
      print ('ndwicollection', ndwicollection);

      var srtm = ee.Image('USGS/SRTMGL1_003');

      var mndwiParams = {min: -1, max: 1, palette: ['green', 'yellow', 'blue']};

      // threshhold


      // Create a label and slider for MNDWI.
      var label = ui.Label('MNDWI Threshold');

      var slider = ui.Slider({
      min:-1,
      max: 1,
      step: 0.01,
      style: {stretch: 'horizontal', width:'500px' },
      onChange: (function(value) {
      Map.layers().reset();
      var ndwi_collection_mask = ndwicollection.updateMask
      (ndwicollection.gte(value));
      Map.addLayer(ndwi_collection_mask, {palette: 'blue'}, 'MNDWI threshold '+String(value));
      return ndwi_collection_mask;})
      });
      slider.setValue(0.0); // Set a default value.

      // Create a label and slider for Elevation.
      var label1 = ui.Label('Elevation');
      var slider1 = ui.Slider({
      min:0,
      max: 3000,
      step: 1,
      style: {stretch: 'horizontal', width:'500px' },
      onChange: (function(value1) {
      Map.layers().reset();
      var srtmmask = srtm.updateMask(srtm.lte(value1));
      Map.addLayer(srtmmask, {palette: 'blue'}, 'MNDWI threshold '+String(value1));
      return srtmmask;})
      });
      slider1.setValue(0); // Set a default value.


      // Create a panel that contains both the slider and the label.
      var panel = ui.Panel({
      widgets: [label, slider, label1,slider1],
      layout: ui.Panel.Layout.flow('vertical'),
      style: {position: 'bottom-right',width: '520px'
      }
      });

      // Add the panel to the map.
      Map.add(panel);

      //// to replace with sliders
      var desired = srtm.updateMask(srtm.lte(100)).and(ndwicollection.updateMask
      (ndwicollection.gte(0)));
      Map.addLayer(desired, {palette: 'blue'});






      google-earth-engine masking timeslider dynamic-layer






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago







      Oscarbau

















      asked 8 hours ago









      OscarbauOscarbau

      186 bronze badges




      186 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          3














          You can do this by calling the same function on either slider change and then accessing the values from the slider directly from within the function which in this case i've named updateLayer



          var slider = ui.Slider({
          min:-1,
          max: 1,
          step: 0.01,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });

          var slider1 = ui.Slider({
          min:0,
          max: 3000,
          step: 1,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });


          The updating function itself will be something like this



          function updateLayer(value){
          var ndwival = slider.getValue();
          var demval = slider1.getValue();
          print(ndwival,demval);
          Map.layers().reset();
          var desired = srtm.updateMask(srtm.lte(demval)).and(ndwicollection
          .updateMask(ndwicollection.gte(ndwival)));
          Map.addLayer(desired, {palette: 'blue'});
          }


          To start things off you can call this function once with any value as argument or none at all. Just a



          updateLayer();


          at the root level of your script should do it or wherever you want for the initial run with default values.






          share|improve this answer




























          • Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

            – Oscarbau
            3 hours ago











          • oops thanks for pointing that out! i'll fix my answer

            – Nishanta Khanal
            2 hours ago














          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f330694%2fmasking-using-two-sliders-on-google-earth-engine%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          You can do this by calling the same function on either slider change and then accessing the values from the slider directly from within the function which in this case i've named updateLayer



          var slider = ui.Slider({
          min:-1,
          max: 1,
          step: 0.01,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });

          var slider1 = ui.Slider({
          min:0,
          max: 3000,
          step: 1,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });


          The updating function itself will be something like this



          function updateLayer(value){
          var ndwival = slider.getValue();
          var demval = slider1.getValue();
          print(ndwival,demval);
          Map.layers().reset();
          var desired = srtm.updateMask(srtm.lte(demval)).and(ndwicollection
          .updateMask(ndwicollection.gte(ndwival)));
          Map.addLayer(desired, {palette: 'blue'});
          }


          To start things off you can call this function once with any value as argument or none at all. Just a



          updateLayer();


          at the root level of your script should do it or wherever you want for the initial run with default values.






          share|improve this answer




























          • Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

            – Oscarbau
            3 hours ago











          • oops thanks for pointing that out! i'll fix my answer

            – Nishanta Khanal
            2 hours ago
















          3














          You can do this by calling the same function on either slider change and then accessing the values from the slider directly from within the function which in this case i've named updateLayer



          var slider = ui.Slider({
          min:-1,
          max: 1,
          step: 0.01,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });

          var slider1 = ui.Slider({
          min:0,
          max: 3000,
          step: 1,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });


          The updating function itself will be something like this



          function updateLayer(value){
          var ndwival = slider.getValue();
          var demval = slider1.getValue();
          print(ndwival,demval);
          Map.layers().reset();
          var desired = srtm.updateMask(srtm.lte(demval)).and(ndwicollection
          .updateMask(ndwicollection.gte(ndwival)));
          Map.addLayer(desired, {palette: 'blue'});
          }


          To start things off you can call this function once with any value as argument or none at all. Just a



          updateLayer();


          at the root level of your script should do it or wherever you want for the initial run with default values.






          share|improve this answer




























          • Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

            – Oscarbau
            3 hours ago











          • oops thanks for pointing that out! i'll fix my answer

            – Nishanta Khanal
            2 hours ago














          3












          3








          3







          You can do this by calling the same function on either slider change and then accessing the values from the slider directly from within the function which in this case i've named updateLayer



          var slider = ui.Slider({
          min:-1,
          max: 1,
          step: 0.01,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });

          var slider1 = ui.Slider({
          min:0,
          max: 3000,
          step: 1,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });


          The updating function itself will be something like this



          function updateLayer(value){
          var ndwival = slider.getValue();
          var demval = slider1.getValue();
          print(ndwival,demval);
          Map.layers().reset();
          var desired = srtm.updateMask(srtm.lte(demval)).and(ndwicollection
          .updateMask(ndwicollection.gte(ndwival)));
          Map.addLayer(desired, {palette: 'blue'});
          }


          To start things off you can call this function once with any value as argument or none at all. Just a



          updateLayer();


          at the root level of your script should do it or wherever you want for the initial run with default values.






          share|improve this answer















          You can do this by calling the same function on either slider change and then accessing the values from the slider directly from within the function which in this case i've named updateLayer



          var slider = ui.Slider({
          min:-1,
          max: 1,
          step: 0.01,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });

          var slider1 = ui.Slider({
          min:0,
          max: 3000,
          step: 1,
          style: {stretch: 'horizontal', width:'500px'},
          onChange: updateLayer
          });


          The updating function itself will be something like this



          function updateLayer(value){
          var ndwival = slider.getValue();
          var demval = slider1.getValue();
          print(ndwival,demval);
          Map.layers().reset();
          var desired = srtm.updateMask(srtm.lte(demval)).and(ndwicollection
          .updateMask(ndwicollection.gte(ndwival)));
          Map.addLayer(desired, {palette: 'blue'});
          }


          To start things off you can call this function once with any value as argument or none at all. Just a



          updateLayer();


          at the root level of your script should do it or wherever you want for the initial run with default values.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 4 hours ago









          Nishanta KhanalNishanta Khanal

          7124 silver badges11 bronze badges




          7124 silver badges11 bronze badges
















          • Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

            – Oscarbau
            3 hours ago











          • oops thanks for pointing that out! i'll fix my answer

            – Nishanta Khanal
            2 hours ago



















          • Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

            – Oscarbau
            3 hours ago











          • oops thanks for pointing that out! i'll fix my answer

            – Nishanta Khanal
            2 hours ago

















          Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

          – Oscarbau
          3 hours ago





          Thanks, after changing the values in 'desired' function for ndwival and demval it worked!

          – Oscarbau
          3 hours ago













          oops thanks for pointing that out! i'll fix my answer

          – Nishanta Khanal
          2 hours ago





          oops thanks for pointing that out! i'll fix my answer

          – Nishanta Khanal
          2 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f330694%2fmasking-using-two-sliders-on-google-earth-engine%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m