In Earth Engine, I want to draw rectangular boxes around points, with the constraint that the box will exactly fit a pixel grid (from another raster).
Drawing a rectangular box around a point has been already discussed (see Creating planar rectangle about points of interest in Google Earth Engine?): use x.buffer(50).bounds()
.
But how can I adjust that box so that it fit exactly a raster grid, i.e. it contains only 100% covered pixels?
See example below, I would like either a smaller box (removing the <100% covered pixels) or bigger (including also the <100% covered pixels). Link for this code: link
var point = ee.Geometry.Point([-103.44862, 25.90856])
var box = point.buffer(50).bounds()
var LS = ee.ImageCollection("LANDSAT/LC8_L1T_32DAY_NDVI")
var pal = ["#000004FF", "#56106EFF", "#BB3754FF", "#F98C0AFF", "#FCFFA4FF"]
// Display the polygon on the map
Map.centerObject(point, 18);
Map.addLayer(point, {color: 'FF0000'}, 'point');
Map.addLayer(ee.Image(LS.first()).clip(box.buffer(30)), {min:0.1, max:0.2, palette: pal}, 'LS');
Map.addLayer(box, {}, 'box');