0

I have uploaded a shapefile to google earth engine and imported it as a table. From the table column, how do I color the coordinate points with respect to the temp_f values that are listed in the uploaded table. This is what I have so far,

var shp = ee.FeatureCollection(temps).limit(5);
var temperatures = shp.select('temp_f');
print(temperatures);
//Temperature parameters
var palette_1 = ee.List(['white', 'blue', 'red']);
var Thermal_vis = ee.Dictionary({
   min: 80,
   max: 89,
   palette: palette_1,
   properties: ['temp_f']
});
Map.addLayer(temperatures,Thermal_vis,'temps');

1 Answer 1

0

Vector features can be colored according to an attribute by "painting" the features onto an image object as follows:

// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0

// Buffer each feature so it is visible.
var radius = 2e2;
var buffered = shp.map(function(f) {return f.buffer(radius)});

// Paint an image with colors defined by a feature attribute.
var empty = ee.Image().byte();
var fills = empty.paint({
  featureCollection: buffered,
  color: 'temp_f'
});

// Display the image on the map.
var ThermalVis = {
  min:80,
  max:89,
  palette: ['white', 'blue', 'red']
};
Map.addLayer(fills, ThermalVis, 'temps (visualization)');

Here is the link to the code: https://code.earthengine.google.com/272178890fd0ea03be1641d60aca740f

More options for styling features can be found in the Feature and FeatureCollection Visualization section of the Earth Engine documentation.

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.