Google Earth Engine (GEE) ——矢量转栅格初学者最易犯的错误

我们都知道有时候我们需要对矢量和栅格进行转化,这样做的目的就是为了方便我们影像统一操作或者其它处理。这里我们会用到GEE中的一个矢量转换栅格的函数,通过这个函数我们可以快速的将矢量转化未栅格,但是这里需要注意的是我们需要查看我们的矢量集合是否会有很多细节,也就是节点比较多,如果太多的话转换过程会很困难,有时候会出现超限的情况,这里建议在转换前大区域复杂的矢量集合需要进行simply进行简化,这样就可以了/、

reduceToImage(properties, reducer)

Creates an image from a feature collection by applying a reducer over the selected properties of all the features that intersect each pixel.

通过对与每个像素相交的所有特征的选定属性应用缩减器,从特征集合创建图像。

Arguments:

this:collection (FeatureCollection):

Feature collection to intersect with each output pixel.

properties (List):

Properties to select from each feature and pass into the reducer.

reducer (Reducer):

A Reducer to combine the properties of each intersecting feature into a final result to store in the pixel.

扫描二维码关注公众号,回复: 14871738 查看本文章

Returns: Image

simplify(maxError, proj)

Simplifies the geometry of a feature to within a given error margin. Note that this does not respect the error margin requested by the consumer of this algorithm, unless maxError is explicitly specified to be null.

This overrides the default Earth Engine policy for propagating error margins, so regardless of the geometry accuracy requested from the output, the inputs will be requested with the error margin specified in the arguments to this algorithm. This results in consistent rendering at all zoom levels of a rendered vector map, but at lower zoom levels (i.e. zoomed out), the geometry won't be simplified, which may harm performance.

将特征的几何简化到给定的误差范围内。 请注意,这不考虑该算法的使用者请求的误差幅度,除非 maxError 明确指定为 null。

这会覆盖用于传播误差范围的默认 Earth Engine 策略,因此无论从输出请求的几何精度如何,都将使用此算法的参数中指定的误差范围来请求输入。 这会导致在渲染矢量图的所有缩放级别上呈现一致的渲染,但在较低的缩放级别(即缩小)下,几何图形不会被简化,这可能会损害性能。

Arguments:

this:feature (Element):

The feature whose geometry is being simplified.

maxError (ErrorMargin):

The maximum amount of error by which the result may differ from the input.

proj (Projection, default: null):

If specified, the result will be in this projection. Otherwise it will be in the same projection as the input. If the error margin is in projected units, the margin will be interpreted as units of this projection

Returns: Feature

原始代码:


var feat_col = ee.FeatureCollection('users/spotter/fire_cnn/buffered_polys/2015')

print(feat_col.first())
Map.addLayer(feat_col, {}, 'Features ')

var img  =  feat_col.reduceToImage({
    properties: ['Year'],
    reducer: ee.Reducer.mean()
    })
    
print(img)

Map.addLayer(img, {}, 'Image')

错误代码:


var img  =  feat_col.reduceToImage({
    properties: ["Date",'Day',"ID","Month",'Year',"count","label"],
    reducer: ee.Reducer.mean()
    })
    
print(img)

 另外一个错误就是不能进行多个属性赋值转化,只能选择单个属性进行转化

另外如果遇到转化影像的过程出现了只能转化其中一个的时候,我们需要在本地将矢量集合进行合并,然后再上传,这样就可以进行完整的矢量转栅格了。 

猜你喜欢

转载自blog.csdn.net/qq_31988139/article/details/130032658