ee.FeatureCollection.style

با استفاده از یک زبان سبک ساده یک مجموعه برداری برای تجسم ترسیم کنید.

استفاده برمی گرداند
FeatureCollection. style ( color , pointSize , pointShape , width , fillColor , styleProperty , neighborhood , lineType ) تصویر
استدلال تایپ کنید جزئیات
این: collection مجموعه ویژگی ها مجموعه ای برای ترسیم
color رشته، پیش فرض: "سیاه" یک رنگ پیش‌فرض (مقدار رنگ CSS 3.0 به عنوان مثال، «FF0000» یا «قرمز») برای استفاده برای ترسیم ویژگی‌ها. از کدورت (به عنوان مثال، 'FF000088' برای 50٪ قرمز شفاف) پشتیبانی می کند.
pointSize عدد صحیح، پیش فرض: 3 اندازه پیش فرض بر حسب پیکسل نشانگرهای نقطه.
pointShape رشته، پیش فرض: "دایره" شکل پیش‌فرض نشانگر برای ترسیم در هر نقطه. یکی از موارد زیر این آرگومان همچنین از این اختصارات نشانگر Matlab پشتیبانی می کند: «o»، «s»، «d»، «x»، «+»، «p»، «h»، «^»، «v»، «<»، «>».
width شناور، پیش فرض: 2 عرض خط پیش فرض برای خطوط و خطوط کلی برای چند ضلعی ها و اشکال نقطه.
fillColor رشته، پیش فرض: null رنگ برای پر کردن چند ضلعی ها و اشکال نقطه. پیش‌فرض «رنگ» در کدورت 0.66 است.
styleProperty رشته، پیش فرض: null یک ویژگی برای هر ویژگی که انتظار می رود حاوی یک فرهنگ لغت باشد. مقادیر موجود در فرهنگ لغت، مقادیر پیش‌فرض آن ویژگی را لغو می‌کنند.
neighborhood عدد صحیح، پیش فرض: 5 اگر از styleProperty استفاده شود و هر ویژگی دارای یک pointSize یا عرض بزرگتر از پیش فرض باشد، مصنوعات کاشی کاری ممکن است رخ دهد. حداکثر همسایگی (pointSize + عرض) مورد نیاز برای هر ویژگی را مشخص می کند.
lineType رشته، پیش فرض: "جامد" سبک خط پیش‌فرض برای خطوط و خطوط کلی چندضلعی‌ها و اشکال نقطه‌ای. پیش‌فرض به «جامد». یکی از: توپر، نقطه چین، چین دار.

نمونه ها

ویرایشگر کد (جاوا اسکریپت)

// 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');

راه اندازی پایتون

برای اطلاعات در مورد API پایتون و استفاده از geemap برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.

import ee
import geemap.core as geemap

کولب (پایتون)

# 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