همانند تصاویر، هندسه ها و ویژگی ها، مجموعه ویژگی ها را می توان مستقیماً با Map.addLayer()
به نقشه اضافه کرد. تجسم پیشفرض بردارها را با خطوط مشکی یکدست و پر کردن سیاه نیمه مات نمایش میدهد. برای نمایش رنگی بردارها، پارامتر color
را مشخص کنید. در زیر مناطق بوم «RESOLVE» ( Dinerstein et al. 2017 ) به عنوان تجسم پیشفرض و با رنگ قرمز نمایش داده میشود:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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
برای گزینه های نمایش اضافی، از featureCollection.draw()
استفاده کنید. به طور خاص، پارامترهای pointRadius
و strokeWidth
به ترتیب اندازه نقاط و خطوط را در FeatureCollection
رندر شده کنترل می کنند:
ویرایشگر کد (جاوا اسکریپت)
Map.addLayer(ecoregions.draw({color: '006600', strokeWidth: 5}), {}, 'drawn');
import ee import geemap.core as geemap
کولب (پایتون)
m.add_layer(ecoregions.draw(color='006600', strokeWidth=5), {}, 'drawn')
خروجی draw()
یک تصویر با نوارهای قرمز، سبز و آبی است که بر اساس پارامتر color
مشخص شده تنظیم شده است.
برای کنترل بیشتر بر نحوه نمایش FeatureCollection
، از image.paint()
با FeatureCollection
به عنوان آرگومان استفاده کنید. برخلاف draw()
که یک تصویر نمایشگر سه باندی و 8 بیتی را خروجی میدهد، image.paint()
تصویری را با مقدار عددی مشخص شده 'painted' در آن خروجی میدهد. همچنین، میتوانید نام یک ویژگی را در FeatureCollection
ارائه کنید که شامل اعداد برای نقاشی است. پارامتر width
به همین صورت عمل می کند: می تواند یک ثابت یا نام یک ویژگی با یک عدد برای عرض خط باشد. به عنوان مثال:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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')
توجه داشته باشید که تصویر خالی که ویژگی ها را در آن نقاشی می کنید باید قبل از نقاشی ریخته شود. این به این دلیل است که یک تصویر ثابت مانند یک ثابت رفتار می کند: به مقدار اولیه گیره می شود. برای رنگ آمیزی لبه های ویژگی با مقادیر تنظیم شده از یک ویژگی ویژگی ها، پارامتر رنگ را به نام ویژگی با مقادیر عددی تنظیم کنید:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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')
هم رنگ و هم عرضی که مرزها با آن ترسیم می شوند را می توان با ویژگی ها تنظیم کرد. به عنوان مثال:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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' )
اگر پارامتر width
ارائه نشده باشد، فضای داخلی ویژگی ها رنگ می شود:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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')
برای ارائه هر دو قسمت داخلی و لبه های ویژگی ها، تصویر خالی را دو بار رنگ کنید:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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', )
همانند تصاویر، هندسه ها و ویژگی ها، مجموعه ویژگی ها را می توان مستقیماً با Map.addLayer()
به نقشه اضافه کرد. تجسم پیشفرض بردارها را با خطوط مشکی یکدست و پر کردن سیاه نیمه مات نمایش میدهد. برای نمایش رنگی بردارها، پارامتر color
را مشخص کنید. در زیر مناطق بوم «RESOLVE» ( Dinerstein et al. 2017 ) به عنوان تجسم پیشفرض و با رنگ قرمز نمایش داده میشود:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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
برای گزینه های نمایش اضافی، از featureCollection.draw()
استفاده کنید. به طور خاص، پارامترهای pointRadius
و strokeWidth
به ترتیب اندازه نقاط و خطوط را در FeatureCollection
رندر شده کنترل می کنند:
ویرایشگر کد (جاوا اسکریپت)
Map.addLayer(ecoregions.draw({color: '006600', strokeWidth: 5}), {}, 'drawn');
import ee import geemap.core as geemap
کولب (پایتون)
m.add_layer(ecoregions.draw(color='006600', strokeWidth=5), {}, 'drawn')
خروجی draw()
یک تصویر با نوارهای قرمز، سبز و آبی است که بر اساس پارامتر color
مشخص شده تنظیم شده است.
برای کنترل بیشتر بر نحوه نمایش FeatureCollection
، از image.paint()
با FeatureCollection
به عنوان آرگومان استفاده کنید. برخلاف draw()
که یک تصویر نمایشگر سه باندی و 8 بیتی را خروجی میدهد، image.paint()
تصویری را با مقدار عددی مشخص شده 'painted' در آن خروجی میدهد. همچنین، میتوانید نام یک ویژگی را در FeatureCollection
ارائه کنید که شامل اعداد برای نقاشی است. پارامتر width
به همین صورت عمل می کند: می تواند یک ثابت یا نام یک ویژگی با یک عدد برای عرض خط باشد. به عنوان مثال:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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')
توجه داشته باشید که تصویر خالی که ویژگی ها را در آن نقاشی می کنید باید قبل از نقاشی ریخته شود. این به این دلیل است که یک تصویر ثابت مانند یک ثابت رفتار می کند: به مقدار اولیه گیره می شود. برای رنگ آمیزی لبه های ویژگی با مقادیر تنظیم شده از یک ویژگی ویژگی ها، پارامتر رنگ را به نام ویژگی با مقادیر عددی تنظیم کنید:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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')
هم رنگ و هم عرضی که مرزها با آن ترسیم می شوند را می توان با ویژگی ها تنظیم کرد. به عنوان مثال:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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' )
اگر پارامتر width
ارائه نشده باشد، فضای داخلی ویژگی ها رنگ می شود:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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')
برای ارائه هر دو قسمت داخلی و لبه های ویژگی ها، تصویر خالی را دو بار رنگ کنید:
ویرایشگر کد (جاوا اسکریپت)
// 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');
import ee import geemap.core as geemap
کولب (پایتون)
# 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', )