0

I am trying to create drop downs that will select features from a feature collection, and have each newly selected feature drawn on the map. I want to have three selectable variables then calculate NDVI for the intersection of the three features. Server side I have managed to filter the feature collections and create a time series of one of the features as seen here:

https://code.earthengine.google.com/1fa976fa661c75326b0b15f66c82ebf4

But I cannot figure out how to create a user environment to select and redraw the selected features. Here, the feature collection layer will disappear when the user selects from the drop down menu, but the feature is not redrawn on the map.

https://code.earthengine.google.com/47c02f60c6ae475e1ba01c0819d57c9f

I would like to calculate a new time series each time the user selects a new set of features based on Forest, county, and municipality.

0

The problem is that you are treating the layer as if it was a feature in your county collection.

This modified code should allow you to select only the feature you want. After that you can run the timeSeries you like one it.

var nmcounties = ee.FeatureCollection("ft:11dWiQkFMNxzP_xHfg98wz9paHoTjlsLRsVwSf0ZZ");
print(nmcounties)
var names = nmcounties.aggregate_array('name');


function onNameChanged(name) {
  print('Update map for ' + name)
}

names.evaluate(function(names) {
  print(names);

  var currentName = ui.Select({
    items: names, 
    placeholder: 'Select County', 
    onChange: redraw,
  });
  var panel = ui.Panel([currentName]);

  Map.widgets().add(panel);
});

var layers = [
  ui.Map.Layer(nmcounties),


];

// The new value is passed as a parameter to the select onChange callback.
function redraw(names) {
    // FILTER THE COLLECTION TO ONLY CONTAIN SELECTED FEATURE
    var myCounty = nmcounties.filterMetadata("name","equals",names)

    // Helper Function to remove all previous layers of the map
    function removeLayersFromMap(layer){
      Map.remove(layer)
    }

    Map.layers().map(removeLayersFromMap)  // map the function to the Map.layers() object
    Map.addLayer(myCounty,{},"county") // Add the new layer to the map
}



Map.addLayer(nmcounties);

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.