公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
地图项和 FeatureCollection 可视化
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
与图片、几何图形和地图项一样,您可以使用 Map.addLayer()
直接将地图项集合添加到地图中。默认可视化结果将以实线和半透明黑色填充显示矢量。如需以颜色渲染矢量,请指定 color
参数。以下显示了“RESOLVE”生态区(Dinerstein 等人,2017)作为默认可视化图表,并以红色显示:
Code Editor (JavaScript)
// Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.
var ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017');
// Display as default and with a custom color.
Map.addLayer(ecoregions, {}, 'default display');
Map.addLayer(ecoregions, {color: 'FF0000'}, 'colored');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.
ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')
# Display as default and with a custom color.
m = geemap.Map()
m.set_center(-76.2486, 44.8988, 8)
m.add_layer(ecoregions, {}, 'default display')
m.add_layer(ecoregions, {'color': 'FF0000'}, 'colored')
m
如需其他显示选项,请使用 featureCollection.draw()
。具体而言,参数 pointRadius
和 strokeWidth
分别控制渲染的 FeatureCollection
中的点和线的大小:
Code Editor (JavaScript)
Map.addLayer(ecoregions.draw({color: '006600', strokeWidth: 5}), {}, 'drawn');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
m.add_layer(ecoregions.draw(color='006600', strokeWidth=5), {}, 'drawn')
draw()
的输出是一个图片,其红色、绿色和蓝色波段的设置取决于指定的 color
参数。
如需更好地控制 FeatureCollection
的显示方式,请使用 image.paint()
并将 FeatureCollection
作为参数。与输出三带 8 位显示图片的 draw()
不同,image.paint()
会输出一个将指定数字值“绘制”到其中的图片。或者,您也可以在 FeatureCollection
中提供一个包含要绘制的数字的属性的名称。width
参数的行为方式相同:它可以是常量,也可以是具有线条宽度数值的属性名称。例如:
Code Editor (JavaScript)
// Create an empty image into which to paint the features, cast to byte.
var empty = ee.Image().byte();
// Paint all the polygon edges with the same number and width, display.
var outline = empty.paint({
featureCollection: ecoregions,
color: 1,
width: 3
});
Map.addLayer(outline, {palette: 'FF0000'}, 'edges');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Create an empty image into which to paint the features, cast to byte.
empty = ee.Image().byte()
# Paint all the polygon edges with the same number and width, display.
outline = empty.paint(featureCollection=ecoregions, color=1, width=3)
m.add_layer(outline, {'palette': 'FF0000'}, 'edges')
请注意,您需要先将要绘制地图项的空图片转换为 Surface,然后才能绘制。这是因为常量图片的行为方式与常量相同:它会被限制在初始化值。如需使用从地图项的属性设置的值为地图项边缘着色,请将 color 参数设置为具有数值的属性名称:
Code Editor (JavaScript)
// Paint the edges with different colors, display.
var outlines = empty.paint({
featureCollection: ecoregions,
color: 'BIOME_NUM',
width: 4
});
var palette = ['FF0000', '00FF00', '0000FF'];
Map.addLayer(outlines, {palette: palette, max: 14}, 'different color edges');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Paint the edges with different colors, display.
outlines = empty.paint(featureCollection=ecoregions, color='BIOME_NUM', width=4)
palette = ['FF0000', '00FF00', '0000FF']
m.add_layer(outlines, {'palette': palette, 'max': 14}, 'different color edges')
您可以使用属性设置绘制边界的颜色和宽度。
例如:
Code Editor (JavaScript)
// Paint the edges with different colors and widths.
var outlines = empty.paint({
featureCollection: ecoregions,
color: 'BIOME_NUM',
width: 'NNH'
});
Map.addLayer(outlines, {palette: palette, max: 14}, 'different color, width edges');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Paint the edges with different colors and widths.
outlines = empty.paint(
featureCollection=ecoregions, color='BIOME_NUM', width='NNH'
)
m.add_layer(
outlines, {'palette': palette, 'max': 14}, 'different color, width edges'
)
如果未提供 width
参数,系统会绘制地图项的内部:
Code Editor (JavaScript)
// Paint the interior of the polygons with different colors.
var fills = empty.paint({
featureCollection: ecoregions,
color: 'BIOME_NUM',
});
Map.addLayer(fills, {palette: palette, max: 14}, 'colored fills');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Paint the interior of the polygons with different colors.
fills = empty.paint(featureCollection=ecoregions, color='BIOME_NUM')
m.add_layer(fills, {'palette': palette, 'max': 14}, 'colored fills')
如需渲染地图项的内部和边缘,请绘制空白图片两次:
Code Editor (JavaScript)
// Paint both the fill and the edges.
var filledOutlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2);
Map.addLayer(filledOutlines, {palette: ['000000'].concat(palette), max: 14}, 'edges and fills');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Paint both the fill and the edges.
filled_outlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2)
m.add_layer(
filled_outlines,
{'palette': ['000000'] + palette, 'max': 14},
'edges and fills',
)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eFeature collections in Earth Engine can be directly added to the map and customized with color using \u003ccode\u003eMap.addLayer()\u003c/code\u003e and the \u003ccode\u003ecolor\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003efeatureCollection.draw()\u003c/code\u003e provides further customization, controlling point and line sizes with \u003ccode\u003epointRadius\u003c/code\u003e and \u003ccode\u003estrokeWidth\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eimage.paint()\u003c/code\u003e offers advanced rendering by 'painting' numeric values or feature properties onto an image, enabling control over fill and edge visualization.\u003c/p\u003e\n"],["\u003cp\u003eFeature boundaries can be styled with varying colors and widths by specifying feature properties for the \u003ccode\u003ecolor\u003c/code\u003e and \u003ccode\u003ewidth\u003c/code\u003e parameters in \u003ccode\u003eimage.paint()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003ePainting an image with a feature collection without specifying \u003ccode\u003ewidth\u003c/code\u003e fills the feature interiors, while subsequent painting can add edges for a combined visualization.\u003c/p\u003e\n"]]],[],null,["# Feature and FeatureCollection Visualization\n\nAs with images, geometries and features, feature collections can be added to the map\ndirectly with `Map.addLayer()`. The default visualization will display the\nvectors with solid black lines and semi-opaque black fill. To render the vectors in color,\nspecify the `color` parameter. The following displays the 'RESOLVE' ecoregions\n([Dinerstein\net al. 2017](https://academic.oup.com/bioscience/article/67/6/534/3102935)) as the default visualization and in red:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.\nvar ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017');\n\n// Display as default and with a custom color.\nMap.addLayer(ecoregions, {}, 'default display');\nMap.addLayer(ecoregions, {color: 'FF0000'}, 'colored');\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# Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.\necoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')\n\n# Display as default and with a custom color.\nm = geemap.Map()\nm.set_center(-76.2486, 44.8988, 8)\nm.add_layer(ecoregions, {}, 'default display')\nm.add_layer(ecoregions, {'color': 'FF0000'}, 'colored')\nm\n```\n\nFor additional display options, use `featureCollection.draw()`. Specifically,\nparameters `pointRadius` and `strokeWidth` control the size of points\nand lines, respectively, in the rendered `FeatureCollection`:\n\n### Code Editor (JavaScript)\n\n```javascript\nMap.addLayer(ecoregions.draw({color: '006600', strokeWidth: 5}), {}, 'drawn');\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\nm.add_layer(ecoregions.draw(color='006600', strokeWidth=5), {}, 'drawn')\n```\n\nThe output of `draw()` is an image with red, green and blue bands set according\nto the specified `color` parameter.\n\nFor more control over how a `FeatureCollection` is displayed, use\n`image.paint()` with the `FeatureCollection` as an argument. Unlike\n`draw()`, which outputs a three-band, 8-bit display image,\n`image.paint()` outputs an image with the specified numeric value 'painted'\ninto it. Alternatively, you can supply the name of a property in the\n`FeatureCollection` which contains the numbers to paint. The `width`\nparameter behaves the same way: it can be a constant or the name of a property with a\nnumber for the line width. For example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create an empty image into which to paint the features, cast to byte.\nvar empty = ee.Image().byte();\n\n// Paint all the polygon edges with the same number and width, display.\nvar outline = empty.paint({\n featureCollection: ecoregions,\n color: 1,\n width: 3\n});\nMap.addLayer(outline, {palette: 'FF0000'}, 'edges');\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# Create an empty image into which to paint the features, cast to byte.\nempty = ee.Image().byte()\n\n# Paint all the polygon edges with the same number and width, display.\noutline = empty.paint(featureCollection=ecoregions, color=1, width=3)\nm.add_layer(outline, {'palette': 'FF0000'}, 'edges')\n```\n\nNote that the empty image into which you paint the features needs to be cast prior to\npainting. This is because a constant image behaves as a constant: it is clamped to the\ninitialization value. To color the feature edges with values set from a property of the\nfeatures, set the color parameter to the name of the property with numeric values:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Paint the edges with different colors, display.\nvar outlines = empty.paint({\n featureCollection: ecoregions,\n color: 'BIOME_NUM',\n width: 4\n});\nvar palette = ['FF0000', '00FF00', '0000FF'];\nMap.addLayer(outlines, {palette: palette, max: 14}, 'different color edges');\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# Paint the edges with different colors, display.\noutlines = empty.paint(featureCollection=ecoregions, color='BIOME_NUM', width=4)\npalette = ['FF0000', '00FF00', '0000FF']\nm.add_layer(outlines, {'palette': palette, 'max': 14}, 'different color edges')\n```\n\nBoth the color and width with which the boundaries are drawn can be set with properties.\nFor example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Paint the edges with different colors and widths.\nvar outlines = empty.paint({\n featureCollection: ecoregions,\n color: 'BIOME_NUM',\n width: 'NNH'\n});\nMap.addLayer(outlines, {palette: palette, max: 14}, 'different color, width edges');\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# Paint the edges with different colors and widths.\noutlines = empty.paint(\n featureCollection=ecoregions, color='BIOME_NUM', width='NNH'\n)\nm.add_layer(\n outlines, {'palette': palette, 'max': 14}, 'different color, width edges'\n)\n```\n\nIf the `width` parameter is not provided, the interior of the features is\npainted:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Paint the interior of the polygons with different colors.\nvar fills = empty.paint({\n featureCollection: ecoregions,\n color: 'BIOME_NUM',\n});\nMap.addLayer(fills, {palette: palette, max: 14}, 'colored fills');\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# Paint the interior of the polygons with different colors.\nfills = empty.paint(featureCollection=ecoregions, color='BIOME_NUM')\nm.add_layer(fills, {'palette': palette, 'max': 14}, 'colored fills')\n```\n\nTo render both the interior and edges of the features, paint the empty image twice:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Paint both the fill and the edges.\nvar filledOutlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2);\nMap.addLayer(filledOutlines, {palette: ['000000'].concat(palette), max: 14}, 'edges and fills');\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# Paint both the fill and the edges.\nfilled_outlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2)\nm.add_layer(\n filled_outlines,\n {'palette': ['000000'] + palette, 'max': 14},\n 'edges and fills',\n)\n```"]]