Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
Feature and FeatureCollection Visualization
Stay organized with collections
Save and categorize content based on your preferences.
As with images, geometries and features, feature collections can be added to the map
directly with Map.addLayer()
. The default visualization will display the
vectors with solid black lines and semi-opaque black fill. To render the vectors in color,
specify the color
parameter. The following displays the 'RESOLVE' ecoregions
(Dinerstein
et al. 2017) as the default visualization and in red:
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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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
For additional display options, use featureCollection.draw()
. Specifically,
parameters pointRadius
and strokeWidth
control the size of points
and lines, respectively, in the rendered FeatureCollection
:
Code Editor (JavaScript)
Map.addLayer(ecoregions.draw({color: '006600', strokeWidth: 5}), {}, 'drawn');
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
Colab (Python)
m.add_layer(ecoregions.draw(color='006600', strokeWidth=5), {}, 'drawn')
The output of draw()
is an image with red, green and blue bands set according
to the specified color
parameter.
For more control over how a FeatureCollection
is displayed, use
image.paint()
with the FeatureCollection
as an argument. Unlike
draw()
, which outputs a three-band, 8-bit display image,
image.paint()
outputs an image with the specified numeric value 'painted'
into it. Alternatively, you can supply the name of a property in the
FeatureCollection
which contains the numbers to paint. The width
parameter behaves the same way: it can be a constant or the name of a property with a
number for the line width. For example:
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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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')
Note that the empty image into which you paint the features needs to be cast prior to
painting. This is because a constant image behaves as a constant: it is clamped to the
initialization value. To color the feature edges with values set from a property of the
features, set the color parameter to the name of the property with numeric values:
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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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')
Both the color and width with which the boundaries are drawn can be set with properties.
For example:
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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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'
)
If the width
parameter is not provided, the interior of the features is
painted:
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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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')
To render both the interior and edges of the features, paint the empty image twice:
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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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',
)
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 2024-06-03 UTC.
[null,null,["Last updated 2024-06-03 UTC."],[[["\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```"]]