使用表格生成要素集
主要功能
使用在線數(shù)據(jù)篩選生成要素集
代碼
// Create a FeatureCollection from a Fusion Table.
// Select "desert" features from the TNC Ecoregions fusion table.
var fc = ee.FeatureCollection('ft:1Ec8IWsP8asxN-ywSqgXWMuBaxI6pPaeh6hC64lA')
.filter(ee.Filter.stringContains('ECO_NAME', 'desert'));
// Paint into a blank image. Cast to byte() so we can use more than 1 color.
var image1 = ee.Image().byte().paint(fc, 'ECO_NUM');
// Display the image using random colors for each value.
Map.setCenter(-109.687, 30.524, 5);
Map.addLayer(image1.randomVisualizer());
步驟分析
- 使用在線數(shù)據(jù)循衰,篩選字段屬性
- 將篩選出的要素輸出到一個數(shù)據(jù)對象中
- 設(shè)置地圖中心,縮放等級
- 添加圖層,展示結(jié)果
主要方法
- ee.FeatureCollection()
FeatureCollections can be constructed from the following arguments:
- A string: assumed to be the name of a collection.
- A single geometry.
- A single feature.
- A list of features.
- A computed object: reinterpreted as a collection.
Arguments:
args (ComputedObject|Feature|FeatureCollection|Geometry|List<Object>|Number|String):
The constructor arguments.
column (String, optional):
The name of the geometry column to use. Only useful with constructor type 1.
Returns: FeatureCollection
創(chuàng)建要素集。
- ee.Filter.stringContains()
Creates a unary or binary filter that passes if the left operand, a string, contains the right operand, also a string.
Arguments:
leftField (String, default: null):
A selector for the left operand. Should not be specified if leftValue is specified.
rightValue (Object, default: null):
The value of the right operand. Should not be specified if rightField is specified.
rightField (String, default: null):
A selector for the right operand. Should not be specified if rightValue is specified.
leftValue (Object, default: null):
The value of the left operand. Should not be specified if leftField is specified.
Returns: Filter
過濾器洼滚,判斷是否包含特定字符串。
輸入?yún)?shù):左屬性(字符串)琳轿,右值判沟,右屬性(字符串),左值
- ee.Image.paint()
Paints the geometries of a collection onto an image.
Arguments:
this:image (Image):
The image on which the collection is painted.
featureCollection (FeatureCollection):
The collection painted onto the image.
color (Object, default: 0):
Either the name of a color property or a number.
width (Object, default: null):
Either the name of a line-width property or a number.
Returns: Image
將地理幾何要素輸出到為影像數(shù)據(jù)崭篡。
輸入?yún)?shù):影像(輸出結(jié)果)挪哄,要素集,顏色琉闪,寬度
- ee.Image.randomVisualizer()
Creates a vizualization image by assigning a random color to each unique value of the pixels of the first band. The first three bands of the output image will contan 8-bit R, G and B values, followed by all bands of the input image.
Arguments:
this:image (Image):
Image with at least one band.
Returns: Image
對影像數(shù)據(jù)的第一波段中的不同值賦予隨機(jī)顏色輸出彩色圖像迹炼,輸出結(jié)果為8位RGB影像
輸入?yún)?shù):影像對象(需至少包含一個波段)