Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 31 characters in body; edited title
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Google earth engineEarth Engine add pixel values to shapefile points and create table as output

Can someone help me please?

Here's my code:

Google earth engine add pixel values to shapefile points and create table as output

Can someone help me please?

Here's my code:

Google Earth Engine add pixel values to shapefile points and create table as output

Here's my code:

Source Link

Google earth engine add pixel values to shapefile points and create table as output

I am very new to GEE and coding, I've searched the web thoroughly for an answer to my question, but I don't understand the answers on the same type of questions.. So therefore I am asking (again) this question.

I am using the Copernicus Global Land Cover dataset together with a shapefile containing point coordinates of small reservoirs (obtained in QGIS). I want to add the pixel values (consisting of the fractions of landcover) of the Land Cover dataset to the shapefile (or a new table with all the information of the reservoir location). However, so far I did create the columns with the possible cover fractions together with the reservoir info, but the cover fraction columns are empty and the reservoir info columns are filled with the corresponding reservoir info.

I thought it might be the issue of using a shapefile, so I created 3 random points in GEE with the geometry function to check. But if I run those 3 points through my model, it only creates 1 row (besides the header row) where the separate values of the specific landcover fraction are all 3 together in 1 cell. So both cases are not going really well and are not the output I want..

Can someone help me please?

Here's my code:

var reservoirs = ee.FeatureCollection("users/jentejanssen/New_Loc_Ghatanji");


var Ghatanji = ee.FeatureCollection("users/jentejanssen/Ghatanji_block");

var multiplepoints = /* color: #d63000 */ee.Geometry.MultiPoint(
        [[78.18223643888375, 20.06380771697672],
         [78.28334597834835, 20.073480721802248],
         [78.26137332209835, 19.99219800350948]]);

var clipToCol = function(image){
  return image.clip(Ghatanji); 
}


//import Copernicus land cover
var dataset = ee.ImageCollection("COPERNICUS/Landcover/100m/Proba-V/Global").map(clipToCol);

//Chose visualization bands 
var visualization = {
  bands: ['discrete_classification'],
  min: 0.0,
  max: 200.0,
  palette: [
    "032f7e","02740b","02740b","8cf502","8cf502","a4da01",
    "ffbd05","ffbd05","7a5a02","f0ff0f","869b36","6091b4",
    "999999","ff4e4e","ff4e4e","ffffff","feffc0","020202",
    "020202",
  ]
};


//Zoom to area and name "Land Cover" layer, this is the layer I want to collect data from
Map.centerObject(Ghatanji,10);
Map.addLayer(dataset, visualization, "Land Cover");

//Display new reservoirs in Ghatanji
Map.addLayer(reservoirs, {color : 'black'}, "reservoirs");

Map.addLayer(multiplepoints, {color : 'red'}, "points");

//Reduce to reservoir regions and retreive land cover data for reservoirs
var reduced = dataset.map(function(image){
  return image.reduceRegions({
    collection: reservoirs, 
    reducer:ee.Reducer.toList(), 
    scale: 30
  });
});

//create table 
var landuse_table = reduced.flatten();

print('reservoir collection land cover', landuse_table);

//Reduce to reservoir regions and retreive land cover data for reservoirs
var reduced_points = dataset.map(function(image){
  return image.reduceRegions({
    collection: multiplepoints, 
    reducer:ee.Reducer.toList(), 
    scale: 30
  });
});

//create table 
var landuse_table_points = reduced_points.flatten();

print('random points collection land cover',landuse_table_points);

// //Export table to drive
// Export.table.toDrive({
//     collection: landuse_table,
//     description: 'landuse_table',
//     fileFormat: 'CSV',
// });

And here's the link to my GEE environment.