0

Is there a way I can export the data from code below into a CSV file to my drive in format of X, Y, WindSpeed? Where X and Y are coordinate of a point in that bounding box.

                              .filter(ee.Filter.date('2022-01-01', '2022-01-02'))
                              .select('u_component_of_wind_10m')ERA5_Land Hourly
                              
var ERA5List = ERA5Collection.toList(ERA5Collection.size())
var ERA5 = ee.Image(ERA5List.get(0))
var bbox2 = region.bounds()
var bbox = ERA5.clip(bbox2)

var visParams = {
  min: -40.0,
  max: 35.0,
  palette: ['blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

var clipERA5 = ERA5.clip(region);
Map.addLayer(clipERA5, visParams, "Wind");
Map.centerObject(clipERA5, 5);
0

1 Answer 1

1

You can use sample to sample each pixel inside a polygon from an image. You then just need to export that data as a table. Since, you did not provide a polygon I am not sure if there are ERA images available for your roi; however, you can add a print before converting the collection to a list, so you are sure that there are images available in that spatiotemporal window.

var resul = ERA5.sample({
  region: region, 
  scale: 27830, // Native resolution of the image
  projection: 'EPSG:4326', // Set a CRS code
  geometries: true // So lat long coordinates are returned
});

Export.table.toDrive({
    collection: ee.FeatureCollection(resul),
    description: 'ERA5_sample'
  });
4
  • How do I do this for entire ImageCollection like export one CSV for each hour for specific time frame or do I have to use a loop and iterate inside var ERA5 = ee.Image(ERA5List.get(i))?
    – pwnkit
    Mar 8, 2023 at 18:32
  • You can map over a list of the dates in your collection to obtain a single image by date. This can be done by filtering the images according to the date and the reducing them using mean, median, etc. Then, you can use toBands to convert the image collection to a multiband image, and finally, use sample to sample the pixels. Mar 8, 2023 at 21:21
  • Thank you for the reply. I think I couldn't explain what I want to achieve in 2nd part. I want to get one CSV for each hour, So 24 CSV's for 24 hours. Taking mean will produce a single CSV of daily average. But I want individual CSV's for each hour. How do I accomplish this? Also I am a beginner to EE, it would be nice if you edited your answer on toBands part.
    – pwnkit
    Mar 9, 2023 at 5:17
  • It would be the same process but instead of reducing by date, you can reduce by date and hour. I suggest that you include all these details in your question and a reproducible example so anyone can try to solve your issue. Also, this way your question and answers will be more useful for future users. Mar 9, 2023 at 15:04

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.