Skip to main content

Google Earth Engine - Pure pixespixels within farm boundaries

edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
Source Link

Google Earth Engine - Pure pixes within farm boundaries

I would like to clip a MODIS image (coarse pixel) with a farm´s limits, but only for the pixels that are fully inside the limits. Looks like when using the "clip" function, it includes a pixel depending on the pixel´s centroid location with respect to the geometry. I tried masking after using the clip function (weights) but I cannot make it work.

var rectangle = ee.Geometry.Polygon(
        [[[-92.53867, 40.18690],[-92.53867, 40.18638],[-92.53750, 40.18638],[-92.53750, 40.18690]]], null, false);
var CDL_2015 = ee.Image('USDA/NASS/CDL/2018')
  .select('cropland')
var mask = CDL_2015
  .clip(rectangle).mask()
  .eq(1) // Supposed that partial pixels will have value < 1. Mask them out

var masked = CDL_2015.updateMask(mask)
Map.addLayer(masked, {}, "PURE")

Is there any easy or already available function to achieve this? I already vectorized and selected as vector´s location but that is unnecessarily a heavy process.

Next a visual example:

Pure MODIS pixels not touching boundaries