0

I'm new to GEE and Java Script but hopefully I can be clear in describing my question. I've been looking through the tutorials and stack overflow but I'm still having difficulty.

I have a csv file consisting of lat/lon locations that I have uploaded with Google Fusion Tables. With my script, I have successfully been able to bin my data into user-defined bins. I wish to display the column truthCloudCover at the resolution from which my data was derived, i.e., 12 km, with a gray-scaled color palette. I am assuming that as I zoom in and out of the visualization, the glyph used to describe the lat/lon point maintains the 12 km resolution. Is this even possible? If so, can you please provide some example? Below I provide my script up to the point where I can bin my data. If you can point me to helpful examples of plotting FeatureCollections at their specified resolutions, I would be very grateful.

I believe you should be able to access my sample data from https://drive.google.com/open?id=1czdOaBYVyu0GA1mcNKIpwEdImsuQqwc0hGudCqv3.

My script for accessing the data and binning it is as follows:

// Load a FeatureCollection from a Fusion Table.
var fromFT = ee.FeatureCollection('ft:1czdOaBYVyu0GA1mcNKIpwEdImsuQqwc0hGudCqv3');
//var selection = fromFT.select('truthCloudCover');

var computePct = function(feature) {
  var trPct = ee.Number(feature.get('truthCloudCover')).divide(100.0);
  var bin = ee.Number(-99);
  if (trPct >= 0.9) {
    bin = ee.Number(3);
  }
  else if (trPct <= 0.1) {
    bin = ee.Number(1);
  }
  else {
    bin = ee.Number(2);
  }  
  return feature.set({bin: bin});
};

var fromFT = fromFT.map(computePct);
// show new property values
print('fromFT', fromFT.limit(6));

var foo = fromFT.select('bin');
print('bin', foo);

var getDict = function(feature) {
  var foo = feature.get('bin'); 
};

var binDict = ee.List.add()

var binDict = fromFT.toDictionary(['name']);
print('binDict', binDict);
Val
  • 6,585
  • 5
  • 22
  • 52
user1745564
  • 159
  • 1
  • 2
  • 8

1 Answers1

0

Finally figured it out. Since I'm new to this, it may not be the most elegant way but posting it anyway. The truthCloudCover column is stratified into bins as follows:

    if truthCloudCover < 0.0 then bin = 0, color is "ffffff"
    if 0.0 <= truthCloudCover <= 10.0 then bin = 1, color is "636363"
    if 10.0 < truthCloudCover < 70.0 then bin = 2, color is "bdbdbd" 
    if truthCloudCover >= 70.0 then bin = 3, color is "f0f0f0"

Solution starts here:

// Load a FeatureCollection from a Fusion Table.
var fromFT = ee.FeatureCollection('ft:1czdOaBYVyu0GA1mcNKIpwEdImsuQqwc0hGudCqv3');

var stratify = function(feature) {
   var val = ee.Number(feature.get('truthCloudCover'));
   val = val.float();
   var bin = ee.Algorithms.If(val.lt(0), 0, 
                              ee.Algorithms.If(val.gte(70), 3,
                                               ee.Algorithms.If(val.lte(10), 1, 2)));
   return feature.set({bin: bin, val: val});
};

var resolution = 12191;

var fromFT = fromFT.map(stratify);

var palette = ee.List(["ffffff", "636363", "bdbdbd", "f0f0f0"]);
var values = ee.List([0,1,2,3]);

var features = fromFT.map(function(f) {
    var bin = f.get("bin");
    // Can't set opacity for a Feature here.  Give buffer radius of resolution
    return f.set({style: {color: palette.get(bin)}}).buffer(resolution/2.0);
});

var layer = Map.addLayer(features.style({styleProperty: "style"}));

layer.setOpacity(0.5);
user1745564
  • 159
  • 1
  • 2
  • 8