公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Image.sampleRectangle
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从图像中提取一个矩形像素区域,并按波段将其放入 ND 数组中。返回的数组位于一个保留了与图像相同属性的要素中,并且几何图形与用于对图像进行采样的几何图形(如果未指定,则为图像覆盖区)相同。每个波段都以其输入投影进行采样,如果未指定几何图形,则使用其覆盖区进行采样。对于标量波段,输出数组为二维数组。对于数组频段,输出数组为 (2+N) 维,其中 N 是原始频段中的维度数。如果对数组频段进行抽样,则所有数组必须具有相同数量的元素。如果某个频段的抽样区域完全被遮盖,并且指定了默认数组值,则使用默认数组值来代替对图片进行抽样。
用法 | 返回 |
---|
Image.sampleRectangle(region, properties, defaultValue, defaultArrayValue) | 功能 |
参数 | 类型 | 详细信息 |
---|
此:image | 图片 | 要抽样的图片。 |
region | 几何图形,默认值:null | 用于对图片进行采样的区域(其投影边界框)。默认为每个频段的覆盖范围。 |
properties | 列表,默认值:null | 要从抽样图片复制的属性。默认为所有非系统属性。 |
defaultValue | 浮点数,默认值:null | 当抽样的像素被遮盖或位于波段覆盖区之外时使用的默认值。 |
defaultArrayValue | 数组,默认值:null | 当采样数组像素被遮盖或位于频段覆盖区之外时使用的默认值。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003esampleRectangle\u003c/code\u003e extracts a rectangular region of pixels from a specified image into a multidimensional array for each band, preserving the image's original properties.\u003c/p\u003e\n"],["\u003cp\u003eThe extracted region is defined by a geometry or defaults to the image's footprint, with each band sampled in its native projection.\u003c/p\u003e\n"],["\u003cp\u003eOutput arrays are 2D for scalar bands and (2+N)D for array bands, where N represents the original band's dimensions, utilizing default values for masked or out-of-bounds pixels if provided.\u003c/p\u003e\n"],["\u003cp\u003eUsers can customize the properties carried over from the original image and specify default values for masked or out-of-bounds pixel values.\u003c/p\u003e\n"]]],["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,["# ee.Image.sampleRectangle\n\nExtracts 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.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------------------------------------------------------------------------------|---------|\n| Image.sampleRectangle`(`*region* `, `*properties* `, `*defaultValue* `, `*defaultArrayValue*`)` | Feature |\n\n| Argument | Type | Details |\n|---------------------|-------------------------|--------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | The image to sample. |\n| `region` | Geometry, default: null | The region whose projected bounding box is used to sample the image. Defaults to the footprint in each band. |\n| `properties` | List, default: null | The properties to copy over from the sampled image. Defaults to all non-system properties. |\n| `defaultValue` | Float, default: null | A default value used when a sampled pixel is masked or outside a band's footprint. |\n| `defaultArrayValue` | Array, default: null | A default value used when a sampled array pixel is masked or outside a band's footprint. |"]]