Now I'm drawing some pixels sampled from map, the code can be run easily:
var first = ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(ee.Geometry.Point(-70.48, 43.3631))
.filterDate('2019-01-01', '2019-12-31')
.sort('CLOUDY_PIXEL_PERCENTAGE')
.first()
var samples = first
.sample({
numPixels: 10,
geometries: true,
})
.map(function(feature) {
var min = 0
var max = 300
var opacity = toHex(min, max, feature.getNumber('B2'))
var fillColor = ee.String('#ff0000').cat(opacity)
return feature
.set('style', {
fillColor: fillColor
})
})
var styled = samples.style({
pointSize: 40,
width: 0,
styleProperty: 'style'
})
Map.addLayer(styled, null, 'samples')
Map.centerObject(samples)
function toHex(min, max, value) {
return ee.Number(value)
.unitScale(min, max)
.multiply(255)
.round()
.clamp(0, 255)
.format('%x')
}
But now I want to draw the pixel size with (500m x 500m) on the map, or you can regard it as a 500x500 size mask. I try to tune the pointSize=500 in fucntion samples.style(), but it seems to be wrong. How can I do it?