公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.FeatureCollection.draw
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
绘制用于可视化的矢量集合。不适合用作其他算法的输入。
用法 | 返回 |
---|
FeatureCollection.draw(color, pointRadius, strokeWidth) | 图片 |
参数 | 类型 | 详细信息 |
---|
此:collection | FeatureCollection | 要绘制的集合。 |
color | 字符串 | 一种格式为 RRGGBB 的十六进制字符串,用于指定绘制地图项时要使用的颜色。 |
pointRadius | 整数,默认值:3 | 点标记的半径(以像素为单位)。 |
strokeWidth | 整数,默认值:2 | 线条和多边形边框的宽度(以像素为单位)。 |
示例
代码编辑器 (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// Paint FeatureCollection to an image for visualization.
var fcVis = fc.draw({color: '800080', pointRadius: 5, strokeWidth: 3});
Map.setCenter(4.56, 50.78, 8);
Map.addLayer(fcVis);
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"'
)
# Paint FeatureCollection to an image for visualization.
fc_vis = fc.draw(color='800080', pointRadius=5, strokeWidth=3)
m = geemap.Map()
m.set_center(4.56, 50.78, 8)
m.add_layer(fc_vis)
m
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003edraw()\u003c/code\u003e visualizes FeatureCollections as images for display purposes, not for algorithmic input.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts color, point radius, and stroke width parameters to customize the visualization.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003edraw()\u003c/code\u003e with FeatureCollections to create image overlays for maps, as demonstrated with the power plants example.\u003c/p\u003e\n"]]],["The `FeatureCollection.draw()` method visualizes a feature collection as an image. It accepts a `FeatureCollection`, a `color` (hex string), `pointRadius` (integer, default 3), and `strokeWidth` (integer, default 2). The method returns an image and is intended for visualization, not algorithmic input. The examples demonstrate how to apply this method using the power plants of Belgium. It can be done in JavaScript or python (colab or not) and the visualization will be an image.\n"],null,["# ee.FeatureCollection.draw\n\nPaints a vector collection for visualization. Not intended for use as input to other algorithms.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------------------------------------|---------|\n| FeatureCollection.draw`(color, `*pointRadius* `, `*strokeWidth*`)` | Image |\n\n| Argument | Type | Details |\n|--------------------|---------------------|-----------------------------------------------------------------------------------------|\n| this: `collection` | FeatureCollection | The collection to draw. |\n| `color` | String | A hex string in the format RRGGBB specifying the color to use for drawing the features. |\n| `pointRadius` | Integer, default: 3 | The radius in pixels of the point markers. |\n| `strokeWidth` | Integer, default: 2 | The width in pixels of lines and polygon borders. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// FeatureCollection of power plants in Belgium.\nvar fc = ee.FeatureCollection('WRI/GPPD/power_plants')\n .filter('country_lg == \"Belgium\"');\n\n// Paint FeatureCollection to an image for visualization.\nvar fcVis = fc.draw({color: '800080', pointRadius: 5, strokeWidth: 3});\nMap.setCenter(4.56, 50.78, 8);\nMap.addLayer(fcVis);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# FeatureCollection of power plants in Belgium.\nfc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(\n 'country_lg == \"Belgium\"'\n)\n\n# Paint FeatureCollection to an image for visualization.\nfc_vis = fc.draw(color='800080', pointRadius=5, strokeWidth=3)\nm = geemap.Map()\nm.set_center(4.56, 50.78, 8)\nm.add_layer(fc_vis)\nm\n```"]]