Google Earth Engine Google Earth Engine GEE method of merging multiple different Assets

  This article introduces how to combine multiple Assets that store point elements into one Asset in GEE .

This article is the fifteenth in   the Google Earth Engine ( GEE ) series of teaching articles. For more GEE articles, please refer to the column: GEE Learning and Application (https://blog.csdn.net/zhebushibiaoshifu/category_11081040.html) .

  First, let's take a look at the requirements that this article needs to implement. There are multiple Assets , which can be our own data or data from other users; among them, each Asset contains different sample points around the world , that is, each Asset is a collection of points . We now hope to combine various Assets into one Asset —that is, to merge a collection of multiple different points into a complete collection of points .

  Once you know the requirements, you can start writing code. The code used in this article is as follows.

var assets_1 = ee.FeatureCollection("users/.../.../grass").map(function(feature) {
    
    
  return feature.set("V_Type", "1");
});
var assets_2 = ee.FeatureCollection("users/.../.../shrub").map(function(feature) {
    
    
  return feature.set("V_Type", "2");
});
var assets_3 = ee.FeatureCollection("users/.../.../crop").map(function(feature) {
    
    
  return feature.set("V_Type", "3");
});
var assets_4 = ee.FeatureCollection("users/.../.../savannas").map(function(feature) {
    
    
  return feature.set("V_Type", "4");
});
var assets_5 = ee.FeatureCollection("users/.../.../EBF").map(function(feature) {
    
    
  return feature.set("V_Type", "5");
});
var assets_6 = ee.FeatureCollection("users/.../.../DBF").map(function(feature) {
    
    
  return feature.set("V_Type", "6");
});
var assets_7 = ee.FeatureCollection("users/.../.../ENF").map(function(feature) {
    
    
  return feature.set("V_Type", "7");
});
var assets_8 = ee.FeatureCollection("users/.../.../DNF").map(function(feature) {
    
    
  return feature.set("V_Type", "8");
});

var merge_assets = ee.FeatureCollection([assets_1, assets_2, assets_3, assets_4, assets_5, assets_6, assets_7, assets_8]).flatten();

Map.addLayer(merge_assets, {
    
    }, "Merged Points");

Export.table.toAsset({
    
    
  collection: merge_assets,
  description: "All_vegetation_types_points",
  assetId: "projects/ee-ucanuse6/assets/AllPoints"
})

  First, the code uses ee.FeatureCollectiona function to load 8a set of points, and uses mapthe function to set V_Typeattributes for each point, whose value is 1~ 8, representing different vegetation types. These point sets are saved into different variables, eg assets_1, assets_2etc. Then, by merging thisee.FeatureCollection([assets_1, assets_2, assets_3, assets_4, assets_5, assets_6, assets_7, assets_8]) set of points into one , and using the function to flatten the nested sets within it into a single one . Finally, use the function to load the merged point set to the map, and use the function to export it to Asset .8FeatureCollectionflattenFeatureCollectionMap.addLayerExport.table.toAssetmerge_assets

  Then, run the above code. We will see the tasks we will perform in the " Tasks " column on the right , as shown in the image below.

Then, click on the " RUN " option   after this task , ready to start executing this task. At this point, the task configuration window will pop up, as shown in the figure below; you can see that the task will be stored in the specified Asset path according to the settings in our preceding code. Of course, at this point we can also manually modify the stored path.

  After confirming that the storage path is correct, we can click the " RUN " option to start the task. Then, the interface as shown in the figure below will appear, and you can see that the task is running.

  Wait for a while, after the task finishes running, we will see the Asset we just exported in the " Assets " interface on the left , that is, the data set that stores all the points; as shown in the figure below. It should be noted here that if you cannot see the Asset we just generated at this time , you can click the refresh button below.

  So far, you're done.

Welcome to pay attention: Crazy learning GIS

Guess you like

Origin blog.csdn.net/zhebushibiaoshifu/article/details/130298921