公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Image.paint
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用给定的“颜色”值将集合的几何图形绘制到图像上,以替换任何几何图形覆盖图像(或如果指定了线宽,则为周长)的每个波段的值。
此算法最适合将特征属性中的类别数据转换为图片中的像素;如果您想可视化集合,请考虑改用 FeatureCollection.style,该方法支持 RGB 颜色,而此算法严格来说是“单色”(使用单个数值)。
用法 | 返回 |
---|
Image.paint(featureCollection, color, width) | 图片 |
参数 | 类型 | 详细信息 |
---|
此:image | 图片 | 绘制合集的图片。 |
featureCollection | FeatureCollection | 绘制到图片上的集合。 |
color | 对象,默认值:0 | 要绘制到输入图像的每个波段中的像素值,可以是用于所有特征的数字,也可以是要从集合中每个特征获取的数值属性的名称。 |
width | 对象,默认值:null | 线条宽度,可以是表示所有几何图形的线条宽度的数字,也可以是要从集合中每个要素获取的数字属性的名称。如果未指定,系统将填充几何图形,而不是描绘轮廓。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003ePaints geometries from a FeatureCollection onto an image, replacing pixel values with a specified color or property value where geometries overlap.\u003c/p\u003e\n"],["\u003cp\u003eIdeal for converting categorical feature data to image pixels, offering a monochrome visualization.\u003c/p\u003e\n"],["\u003cp\u003eOffers options to fill geometries or outline them using a specified line width, which can be uniform or vary based on feature properties.\u003c/p\u003e\n"],["\u003cp\u003eUses a single color value for all bands of the image, making it suitable for thematic mapping and data representation rather than visual styling.\u003c/p\u003e\n"],["\u003cp\u003eFor visualizing collections with RGB colors and more styling options, FeatureCollection.style is recommended as a more suitable alternative.\u003c/p\u003e\n"]]],[],null,["# ee.Image.paint\n\nPaints the geometries of a collection onto an image, using the given 'color' value to replace each band's values where any geometry covers the image (or, if a line width is specified, where the perimeters do).\n\n\u003cbr /\u003e\n\nThis algorithm is most suitable for converting categorical data from feature properties to pixels in an image; if you wish to visualize a collection, consider using FeatureCollection.style instead, which supports RGB colors whereas this algorithm is strictly 'monochrome' (using single numeric values).\n\n| Usage | Returns |\n|---------------------------------------------------------|---------|\n| Image.paint`(featureCollection, `*color* `, `*width*`)` | Image |\n\n| Argument | Type | Details |\n|---------------------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | The image on which the collection is painted. |\n| `featureCollection` | FeatureCollection | The collection painted onto the image. |\n| `color` | Object, default: 0 | The pixel value to paint into every band of the input image, either as a number which will be used for all features, or the name of a numeric property to take from each feature in the collection. |\n| `width` | Object, default: null | Line width, either as a number which will be the line width for all geometries, or the name of a numeric property to take from each feature in the collection. If unspecified, the geometries will be filled instead of outlined. |"]]