1

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

1 Answer 1

1

You can reproject() the mask to do this. It's something you have to be careful with in general though. After reprojecting, the scale of the projection (30 meters in this case) will be used independent on your zoom level. So don't zoom out too far, otherwise too many pixels will be evaluated and things start to fail.

You can read up on scale and projection in EE here and here.

var mask = CDL_2015
  .clip(rectangle)
  .mask()
  .reproject(CDL_2015.projection()) // Be careful with this
  .eq(1) // Sub-pixels will be less than 1

https://code.earthengine.google.com/0c8dace3620c04f891008f59ef31707b

0

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.