Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.
ee.Image.sampleRectangle
Stay organized with collections
Save and categorize content based on your preferences.
Extracts a rectangular region of pixels from an image into a ND 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 its footprint. For scalar bands, the output array is 2D. For array bands the output array is (2+N)D where N is the number of dimensions in the original band. If sampling array bands, all arrays must have the same number of elements. If a band's sampled region is entirely masked and a default array value is specified, the default array value is used in-lieu of sampling the image.
Usage | Returns | Image.sampleRectangle(region, properties, defaultValue, defaultArrayValue) | Feature |
Argument | Type | Details | this: image | Image | The image to sample. |
region | Geometry, default: null | The region whose projected bounding box is used to sample the image. Defaults to the footprint in each band. |
properties | List, default: null | The properties to copy over from the sampled image. Defaults to all non-system properties. |
defaultValue | Float, default: null | A default value used when a sampled pixel is masked or outside a band's footprint. |
defaultArrayValue | Array, default: null | A default value used when a sampled array pixel is masked or outside a band's footprint. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],["It extracts a rectangular pixel region from an image into an ND array per band, returning a feature with the same properties and geometry as the input. Bands are sampled in their input projection using a specified region or the image footprint. Output arrays are 2D for scalar bands and (2+N)D for array bands. If a sampled region is entirely masked, a specified default value or array is used. Properties from the image can be copied.\n"],null,[]]