欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Google Earth Engine 将 Raster 转换为 Vector(reduceToVectors)

程序员文章站 2022-05-26 19:10:20
...
var geometry = ee.Geometry.Rectangle([29.1796875, 32.02670629333615, 32.607421875, 29.993002284551075]);
var landcover = ee.Image('MCD12Q1/MCD12Q1_005_2001_01_01').select('Land_Cover_Type_1');

// Run reduceToVectors per class by masking all other classes.
var classes = ee.List([0, 1, 2, 3, 4, 5, 6, 7, 8])
  .map(function(n) {
    var classImage = landcover.eq(ee.Number(n));
    var vectors = classImage.updateMask(classImage)
      .reduceToVectors({
        reducer: ee.Reducer.countEvery(), 
        geometry: geometry, 
        scale: 30,
        maxPixels: 1e8})
      .geometry();
    return ee.Feature(vectors, {"class": n});
  });
var result = ee.FeatureCollection(classes);
Map.addLayer(result);

Google Earth Engine 将 Raster 转换为 Vector(reduceToVectors)
最好是每一个polygon都有一个feature

var geometry = ee.Geometry.Rectangle([29.1796875, 32.02670629333615, 32.607421875, 29.993002284551075]);
var landcover = ee.Image('MCD12Q1/MCD12Q1_005_2001_01_01').select('Land_Cover_Type_1');

var classes = landcover.reduceToVectors({
  reducer: ee.Reducer.countEvery(), 
  geometry: geometry, 
  scale: 30,
  maxPixels: 1e8
});
var result = ee.FeatureCollection(classes);
Map.addLayer(result);

Google Earth Engine 将 Raster 转换为 Vector(reduceToVectors)

原文链接
原文链接