Extracts a rectangular region of pixels from an image into a 2D array per band. The arrays are returned in a feature retaining the same properties as the image and a geometry the same as that used to sample the image (or the image footprint if unspecified). Each band is sampled in its input projection, and if no geometry is specified, sampled using it's footprint.

Image.sampleRectangle(region, properties, defaultValue)Feature
this: imageImage

The image to sample.

regionGeometry, default: null

The region whose projected bounding box is used to sample the image. Defaults to the footprint in each band.

propertiesList, default: null

The properties to copy over from the sampled image. Defaults to all non-system properties.

defaultValueFloat, default: null

A default value used when a sampled pixel is masked or outside a band's footprint.