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.
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)
另外一个错误就是不能进行多个属性赋值转化,只能选择单个属性进行转化
另外如果遇到转化影像的过程出现了只能转化其中一个的时候,我们需要在本地将矢量集合进行合并,然后再上传,这样就可以进行完整的矢量转栅格了。
相关文章
- Google Earth Engine 实现 LandTrendr 光谱-时间分割算法的指南(运行 LT-GEE)
- Google Earth Engine(GEE)——缩放错误指南(聚合过多、超出内存、超出最大像素和超出内存限制)!
- Google Earth Engine(GEE)——容易犯的错误6(reduceRegion()与. reduceRegions()与. for循环)
- Google Earth Engine(GEE)——给矢量添加时间属性(解决方案)含错误的添加方式
- Google Earth Engine (GEE)——公式expression表达式容易犯的错误
- Google Earth Engine(GEE)——Line 32: NDSI.lt is not a function错误分析
- Google Earth Engine(GEE)——用10米分辨率土地分类数据进行土地面积计算出现错误
- Google Earth Engine——Error: Image.clipToBoundsAndScale, argument ‘input‘: Invalid type的错误解决
- Google Earth Engine(GEE)——found inconsistent types: UInt16 and Byte.影像数据导出到Google硬盘中的错误
- Google Earth Engine(GEE)——export影像导出错误Error: Image.clipToBoundsAndScale, argument ‘input‘: Invalid
- Google Earth Engine(GEE)——调试(语法和客户端)错误指南!
- Google Earth Engine(GEE)——服务器端错误(指南)!
- Google Earth Engine(GEE)——容易犯的错误7(JOIN 和Fiter)
- Google Earth Engine(GEE)——容易犯的错误3(不必要的情况下不要使用clip())
- Google Earth Engine(GEE)——容易犯的错误3(请在select之前使用filter )和(用updateMask()代替mask())、组合reducer的使用!
- Google称赛门铁克发布了3万个错误证书 将限制访问