Google Earth Engine (GEE) - the most common mistake for vector to raster beginners

We all know that sometimes we need to convert vectors and rasters. The purpose of this is to facilitate the unified operation or other processing of our images. Here we will use a vector-to-raster function in GEE. Through this function, we can quickly convert vectors to rasters, but what we need to pay attention to here is that we need to check whether our vector collection will have many details, and also There are too many nodes. If there are too many, the conversion process will be very difficult, and sometimes there will be an overrun situation. It is recommended that the complex vector collection of a large area needs to be simplified before conversion, so that it is ok/,

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.

Creates an image from a collection of features by applying a reducer to selected attributes of all features intersected by 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.

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.

Simplifies the geometry of a feature to within a given margin of error. Note that this does not take into account the margin of error requested by the user of the algorithm, unless maxError is explicitly specified as null.

This overrides the default Earth Engine strategy for propagating the error bounds, so that regardless of the geometric precision requested from the output, the input will be requested with the error bounds specified in the parameters of this algorithm. This results in a consistent rendering at all zoom levels at which vector graphics are rendered, but at lower zoom levels (i.e. zoomed out) the geometry is not simplified, which can hurt performance.

 

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

Original code:


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

error code:


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

 Another mistake is that multiple attribute assignment conversions cannot be performed, and only a single attribute can be selected for conversion

In addition, if only one of them can be converted during the image conversion process, we need to merge the vector collections locally and then upload them, so that the complete vector to raster conversion can be performed. 

Guess you like

Origin blog.csdn.net/qq_31988139/article/details/130032658