1

I have a point coordinate value, and I am trying to extract the surface pressure value and export it to a CSV file from the ERA5 Hourly dataset on google earth engine; however, I am getting an error List.get, argument 'list': Invalid type. Expected type: List. Actual type: Float. Actual value: 99456.6416015625 (Error code: 3). I was able to use the same code to extract the u component and the v component of the wind. Here is my code snippet.

var point = ee.Geometry.Point([77.1272, 28.8107]);
Map.addLayer(point);
Map.centerObject(point);

var dataset = ee.ImageCollection("ECMWF/ERA5_LAND/HOURLY");

var startDate = ee.Date('2019-01-01');
var endDate = ee.Date('2021-01-01');
var diff = endDate.difference(startDate, 'day');

var ucomponent = dataset.select('surface_pressure')
              .filterDate(startDate, endDate);
var list_ucomponent = ucomponent.toList(dataset.size());

var getucomponent = function(image) {

var value_ucomponent = ee.Image(image)
.reduceRegion(ee.Reducer.first(), point)
.get('surface_pressure');
 var time = ee.Image(image).get('system:time_start');
 return value_ucomponent;
 }

 var u_list = list_ucomponent.map(getucomponent);

 var allDates = ee.List(ucomponent.aggregate_array('system:time_start'));
 
 var allDatesSimple = allDates.map(function(date){
 return ee.Date(date).format().slice(0,10);
 }).distinct();

 var len = u_list.size();
 var list = ee.List.sequence(0, len.subtract(1), 24);

 var mean_u_list = list.map(function(ele){

 var start = ee.Number(ele).int(); 
 var end = ee.Number(ele).add(24).int(); 

 var new_list = ee.List([]);
 var element = ee.List(u_list.slice(start, end)).reduce(ee.Reducer.mean());

 new_list = new_list.add(element);

 return new_list;

 }).flatten();

 var myFeatures = ee.FeatureCollection(mean_u_list.map(function(el){
 el = ee.List(el); // cast every element of the list
 var geom = point;
 return ee.Feature(geom, {
'date': ee.String(el.get(0)),
'values':ee.List(el.get(1))
});
}));

Export.table.toDrive(myFeatures,
"hourly", //my task
"GEE_Folder", //my export folder
"hourly_data",  //file name
"CSV");

I am very new to Google Earth Engine.

1 Answer 1

1

Problem is produced because you are trying to map a wrong list (mean_u_list doesn't have dates). Fixed list is named paired in following script (it includes dates now). It has the properties date and values that you want to export. By the way, I reduced the dates range for speeding up the export process.

var point = ee.Geometry.Point([77.1272, 28.8107]);
Map.addLayer(point);
Map.centerObject(point);

var dataset = ee.ImageCollection("ECMWF/ERA5_LAND/HOURLY");

var startDate = ee.Date('2019-01-01');
var endDate = ee.Date('2019-02-01');
var diff = endDate.difference(startDate, 'day');

var ucomponent = dataset.select('surface_pressure')
              .filterDate(startDate, endDate);
var list_ucomponent = ucomponent.toList(dataset.size());

var getucomponent = function(image) {

  var value_ucomponent = ee.Image(image)
    .reduceRegion(ee.Reducer.first(), point)
    .get('surface_pressure');
    var time = ee.Image(image).get('system:time_start');
    return value_ucomponent;
};

var u_list = list_ucomponent.map(getucomponent);

var allDates = ee.List(ucomponent.aggregate_array('system:time_start'));
 
var allDatesSimple = allDates.map(function(date){
 
 return ee.Date(date).format().slice(0,10);

}).distinct();

var len = u_list.size();
var list = ee.List.sequence(0, len.subtract(1), 24);

var mean_u_list = list.map(function(ele){

var start = ee.Number(ele).int(); 
var end = ee.Number(ele).add(24).int(); 

var new_list = ee.List([]);
var element = ee.List(u_list.slice(start, end)).reduce(ee.Reducer.mean());

new_list = new_list.add(element);

  return new_list;

}).flatten();

print(mean_u_list);

var paired = allDatesSimple.zip(mean_u_list);

var myFeatures = ee.FeatureCollection(paired.map(function(el){

  return ee.Feature(null, {
    'date': ee.List(el).get(0),
    'values': ee.List(el).get(1)
  });
}));

print(myFeatures);

Export.table.toDrive(myFeatures,
"hourly", //my task
"GEE_Folder", //my export folder
"hourly_data",  //file name
"CSV");

After running it in GEE code editor, task produces result as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.