在做地物分类的时候我们会采用GEE在线采集样本方式,但是这个有一个问题需要注意,如果直接使用绘制矩形和点会将点变为 ee.Geometry.Point([xxx], null, false) 这种形式。出现的问题步骤如下:
1、绘制一个点和一个矩形
2、修改geometry为featureCollection
3、代码就会变为如下
var geometry =
/* color: #d63000 */
/* displayProperties: [
{
"type": "marker"
},
{
"type": "rectangle"
}
] */
ee.FeatureCollection(
[ee.Feature(
ee.Geometry.Point([-103.11015624999999, 38.67238595631427], null, false),
{
"system:index": "0"
}),
ee.Feature(
ee.Geometry.Polygon(
[[[-100.56132812499999, 37.006674574025816],
[-100.56132812499999, 35.946614423999264],
[-99.24296874999999, 35.946614423999264],
[-99.24296874999999, 37.006674574025816]]], null, false),
{
"system:index": "1"
})]);
这里可以看到明确的问题,point明明只有这两个参数,这里却有三个参数。
4、直接运行会报错
1、新增polygon
2、代码变为了
var geometry =
/* color: #d63000 */
/* displayProperties: [
{
"type": "marker"
},
{
"type": "rectangle"
},
{
"type": "polygon"
}
] */
ee.FeatureCollection(
[ee.Feature(
ee.Geometry.Point([-103.11015624999999, 38.67238595631427]),
{
"system:index": "0"
}),
ee.Feature(
ee.Geometry.Polygon(
[[[-100.56132812499999, 37.006674574025816],
[-100.56132812499999, 35.946614423999264],
[-99.24296874999999, 35.946614423999264],
[-99.24296874999999, 37.006674574025816]]], null, false),
{
"system:index": "1"
}),
ee.Feature(
ee.Geometry.Polygon(
[[[-98.01249999999999, 37.49638919703745],
[-96.60624999999999, 38.259489368377466],
[-98.62773437499999, 38.6037340822239]]]),
{
"system:index": "2"
})]);
3、运行代码