Anúncio: todos os projetos não comerciais registrados para usar o Earth Engine antes de
15 de abril de 2025 precisam
verificar a qualificação não comercial para manter o acesso. Se você não fizer a verificação até 26 de setembro de 2025, seu acesso poderá ser suspenso.
ee.FeatureCollection.style
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Desenhe uma coleção de vetores para visualização usando uma linguagem de estilo simples.
| Uso | Retorna |
|---|
FeatureCollection.style(color, pointSize, pointShape, width, fillColor, styleProperty, neighborhood, lineType) | Imagem |
| Argumento | Tipo | Detalhes |
|---|
isso: collection | FeatureCollection | A coleção a ser desenhada. |
color | String, padrão: "black" | Uma cor padrão (valor de cor CSS 3.0, por exemplo, "FF0000" ou "red") para usar no desenho dos recursos. Compatível com opacidade (por exemplo, "FF000088" para vermelho 50% transparente). |
pointSize | Número inteiro, padrão: 3 | O tamanho padrão em pixels dos marcadores de ponto. |
pointShape | String, padrão: "circle" | A forma padrão do marcador a ser desenhada em cada local. Uma destas opções: "circle", "square", "diamond", "cross", "plus", "pentagram", "hexagram", "triangle", "triangle_up", "triangle_down", "triangle_left", "triangle_right", "pentagon", "hexagon", "star5", "star6". Esse argumento também aceita estas abreviações de marcadores do Matlab: "o", "s", "d", "x", "+", "p", "h", "^", "v", "<", ">". |
width | Ponto flutuante, padrão: 2 | A largura de linha padrão para linhas e contornos de polígonos e formas de pontos. |
fillColor | String, padrão: null | A cor para preencher polígonos e formas de pontos. O padrão é "color" com opacidade de 0,66. |
styleProperty | String, padrão: null | Uma propriedade por recurso que deve conter um dicionário. Os valores no dicionário substituem os valores padrão desse recurso. |
neighborhood | Número inteiro, padrão: 5 | Se "styleProperty" for usado e algum recurso tiver um "pointSize" ou uma largura maior que os padrões, poderão ocorrer artefatos de segmentação. Especifica a vizinhança máxima (pointSize + largura) necessária para qualquer recurso. |
lineType | String, padrão: "solid" | O estilo de linha padrão para linhas e contornos de polígonos e formas de pontos. O padrão é "solid". Uma destas opções: sólido, pontilhado, tracejado. |
Exemplos
Editor de código (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// Paint FeatureCollection to an image using collection-wide style arguments.
var fcVis = fc.style({
color: '1e90ff',
width: 2,
fillColor: 'ff475788', // with alpha set for partial transparency
lineType: 'dotted',
pointSize: 10,
pointShape: 'circle'
});
// Display the FeatureCollection visualization (ee.Image) on the map.
Map.setCenter(4.326, 50.919, 9);
Map.addLayer(fcVis, null, 'Collection-wide style');
// Paint FeatureCollection to an image using feature-specific style arguments.
// A dictionary of style properties per power plant fuel type.
var fuelStyles = ee.Dictionary({
Wind: {color: 'blue', pointSize: 5, pointShape: 'circle'},
Gas: {color: 'yellow', pointSize: 6, pointShape: 'square'},
Oil: {color: 'green', pointSize: 3, pointShape: 'diamond'},
Coal: {color: 'red', pointSize: 3, pointShape: 'cross'},
Hydro: {color: 'brown', pointSize: 3, pointShape: 'star5'},
Biomass: {color: 'orange', pointSize: 4, pointShape: 'triangle'},
Nuclear: {color: 'purple', pointSize: 6, pointShape: 'hexagram'},
});
// Add feature-specific style properties to each feature based on fuel type.
fc = fc.map(function(feature) {
return feature.set('style', fuelStyles.get(feature.get('fuel1')));
});
// Style the FeatureCollection according to each feature's "style" property.
var fcVisCustom = fc.style({
styleProperty: 'style',
neighborhood: 8 // maximum "pointSize" + "width" among features
});
// Display the FeatureCollection visualization (ee.Image) on the map.
Map.addLayer(fcVisCustom, null, 'Feature-specific style');
Configuração do Python
Consulte a página
Ambiente Python para informações sobre a API Python e como usar
geemap para desenvolvimento interativo.
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 using collection-wide style arguments.
fc_vis = fc.style(
color='1e90ff',
width=2,
fillColor='ff475788', # with alpha set for partial transparency
lineType='dotted',
pointSize=10,
pointShape='circle',
)
# Display the FeatureCollection visualization (ee.Image) on the map.
m = geemap.Map()
m.set_center(4.326, 50.919, 9)
m.add_layer(fc_vis, None, 'Collection-wide style')
# Paint FeatureCollection to an image using feature-specific style arguments.
# A dictionary of style properties per power plant fuel type.
fuel_styles = ee.Dictionary({
'Wind': {'color': 'blue', 'pointSize': 5, 'pointShape': 'circle'},
'Gas': {'color': 'yellow', 'pointSize': 6, 'pointShape': 'square'},
'Oil': {'color': 'green', 'pointSize': 3, 'pointShape': 'diamond'},
'Coal': {'color': 'red', 'pointSize': 3, 'pointShape': 'cross'},
'Hydro': {'color': 'brown', 'pointSize': 3, 'pointShape': 'star5'},
'Biomass': {'color': 'orange', 'pointSize': 4, 'pointShape': 'triangle'},
'Nuclear': {'color': 'purple', 'pointSize': 6, 'pointShape': 'hexagram'},
})
# Add feature-specific style properties to each feature based on fuel type.
fc = fc.map(
lambda feature: feature.set('style', fuel_styles.get(feature.get('fuel1')))
)
# Style the FeatureCollection according to each feature's "style" property.
fc_vis_custom = fc.style(
styleProperty='style',
neighborhood=8, # maximum "pointSize" + "width" among features
)
# Display the FeatureCollection visualization (ee.Image) on the map.
m.add_layer(fc_vis_custom, None, 'Feature-specific style')
m
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-07-26 UTC.
[null,null,["Última atualização 2025-07-26 UTC."],[],[]]