ee.FeatureCollection.style

간단한 스타일 언어를 사용하여 시각화를 위한 벡터 컬렉션을 그립니다.

사용반환 값
FeatureCollection.style(color, pointSize, pointShape, width, fillColor, styleProperty, neighborhood, lineType)이미지
인수유형세부정보
다음과 같은 경우: collectionFeatureCollection그릴 컬렉션입니다.
color문자열, 기본값: 'black'기본 색상 (CSS 3.0 색상 값, 예: 'FF0000' 또는 'red')을 지정합니다. 불투명도를 지원합니다 (예: 'FF000088'은 50% 투명한 빨간색입니다.
pointSize정수, 기본값: 3포인트 마커의 기본 크기(픽셀)입니다.
pointShape문자열, 기본값: 'circle'각 포인트 위치에 그릴 마커의 기본 모양입니다. `circle`, `square`, `diamond`, `cross`, `plus`, `pentagram`, `hexagram`, `triangle`, `triangle_up`, `triangle_down`, `triangle_left`, `triangle_right`, `pentagon`, `hexagon`, `star5`, `star6` 중 하나입니다. 이 인수는 Matlab 마커 약어(`o`, `s`, `d`, `x`, `+`, `p`, `h`, `^`, `v`, `<`, `>`)도 지원합니다.
width부동 소수점 수, 기본값: 2선과 다각형 및 점 도형의 윤곽선의 기본 선 너비입니다.
fillColor문자열, 기본값: null다각형 및 점 모양을 채우는 색상입니다. 기본값은 불투명도 0.66의 'color'입니다.
styleProperty문자열, 기본값: null사전을 포함할 것으로 예상되는 기능별 속성입니다. 사전의 값은 해당 기능의 기본값을 재정의합니다.
neighborhood정수, 기본값: 5styleProperty를 사용하고 포인트 크기 또는 너비가 기본값보다 큰 기능이 있으면 타일링 아티팩트가 발생할 수 있습니다. 모든 특징에 필요한 최대 이웃 (pointSize + width)을 지정합니다.
lineType문자열, 기본값: 'solid'선과 다각형 및 점 모양의 윤곽선의 기본 선 스타일입니다. 기본값은 'solid'입니다. 다음 중 하나: solid, dotted, dashed

코드 편집기 (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');

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 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