Anuncio: Todos los proyectos no comerciales registrados para usar Earth Engine antes del
15 de abril de 2025 deben
verificar su elegibilidad no comercial para mantener el acceso. Si no realizas la verificación antes del 26 de septiembre de 2025, es posible que se suspenda tu acceso.
ee.FeatureCollection.style
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Dibuja una colección de vectores para la visualización con un lenguaje de estilo simple.
| Uso | Muestra |
|---|
FeatureCollection.style(color, pointSize, pointShape, width, fillColor, styleProperty, neighborhood, lineType) | Imagen |
| Argumento | Tipo | Detalles |
|---|
esta: collection | FeatureCollection | Es la colección que se dibujará. |
color | Cadena. El valor predeterminado es "black". | Un color predeterminado (valor de color CSS 3.0, p.ej., "FF0000" o "rojo") que se usará para dibujar los atributos. Admite opacidad (p.ej., "FF000088" para rojo transparente en un 50%). |
pointSize | Número entero, valor predeterminado: 3 | Es el tamaño predeterminado en píxeles de los marcadores de puntos. |
pointShape | Cadena, valor predeterminado: "circle" | Es la forma predeterminada del marcador que se dibujará en cada ubicación de punto. Uno de los siguientes: "circle", "square", "diamond", "cross", "plus", "pentagram", "hexagram", "triangle", "triangle_up", "triangle_down", "triangle_left", "triangle_right", "pentagon", "hexagon", "star5", "star6". Este argumento también admite las siguientes abreviaturas de marcadores de Matlab: "o", "s", "d", "x", "+", "p", "h", "^", "v", "<", ">". |
width | Número de punto flotante, valor predeterminado: 2 | Es el ancho de línea predeterminado para las líneas y los contornos de polígonos y formas de puntos. |
fillColor | Cadena, valor predeterminado: nulo | Es el color para rellenar polígonos y formas de puntos. La configuración predeterminada es “color” con una opacidad de 0.66. |
styleProperty | Cadena, valor predeterminado: nulo | Es una propiedad por atributo que se espera que contenga un diccionario. Los valores del diccionario anulan cualquier valor predeterminado para esa función. |
neighborhood | Número entero, valor predeterminado: 5 | Si se usa styleProperty y alguna función tiene un pointSize o un ancho mayor que los valores predeterminados, pueden producirse artefactos de segmentación. Especifica el vecindario máximo (pointSize + width) necesario para cualquier atributo. |
lineType | Cadena. El valor predeterminado es "solid". | Es el estilo de línea predeterminado para las líneas y los contornos de polígonos y formas de puntos. El valor predeterminado es “solid”. Una de las siguientes opciones: sólida, punteada o discontinua |
Ejemplos
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');
Configuración de Python
Consulta la página
Entorno de Python para obtener información sobre la API de Python y el uso de geemap para el desarrollo interactivo.
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
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-26 (UTC)
[null,null,["Última actualización: 2025-07-26 (UTC)"],[],[]]