# Joining wind speed and wind direction using Google Earth Engine

I have successfully exported wind speed to a csv file, and am trying to add wind direction. I know my wind direction calculation works and I can see it when printing `ERA5total`. If I understand correctly, I need to use an inner join, but I only end up with an empty csv file.

``````//  1. Setup
var countries = ee.FeatureCollection("FAO/GAUL/2015/level0");
var start_period = ee.Date('2018-07-01');
var end_period = ee.Date(new Date().getTime());

var ERA5 = ee.ImageCollection("ECMWF/ERA5_LAND/HOURLY")
.filter(ee.Filter.date(start_period, end_period))

var ERA5NL=ERA5.map(function(image){
return image.clip(NL)});

//  2. Calculate wind speed as windspeed band
var ERA5windspeed = ERA5NL.map(function(image){
var wind_10m = image.expression(
'sqrt(u**2 + v**2)', {
'u': image.select('u_component_of_wind_10m'),
'v': image.select('v_component_of_wind_10m')
}).rename('windspeed');
var time = image.get('system:time_start');
return wind_10m.set('system:time_start', time) } );

//  3. Calculate mean wind speed for entire NL per day
var ERA5meanspeed = ERA5windspeed.map(function(image){
var meandict = image.select('windspeed').reduceRegion({
reducer: ee.Reducer.mean(),
geometry: NL
})
return image.set(meandict);
});

//  4. Calculate wind direction as winddir band
var ERA5winddir = ERA5NL.map(function(image){
var winddir = image.expression(
'mod(180 + (180/3.14) * atan2(v,u),360)', {
'u': image.select('u_component_of_wind_10m'),
'v': image.select('v_component_of_wind_10m')
}).rename('winddir');
var time = image.get('system:time_start');
return winddir.set('system:time_start', time) } );

//  5. Calculate mean wind direction for entire NL per day
var ERA5meandir = ERA5winddir.map(function(image){
var meandict = image.select('winddir').reduceRegion({
reducer: ee.Reducer.mean(),
geometry: NL
})
return image.set(meandict);
});

//6. Join wind speed and wind direction datasets

// Use an equals filter to define how the collections match.
var filter = ee.Filter.equals({
leftField: 'system:index',
rightField: 'system:index',
});

// Define the join.
var innerJoin = ee.Join.inner('primary', 'secondary');

// Apply the join.
var ERA5total = innerJoin.apply(ERA5meanspeed, ERA5meandir, filter);

// Display the result.
print('Join', ERA5total);

//7. Filter out wind speeds > 3 m/s and keep only yyyymmdd in output table
var ERA5x = ERA5total.filter(ee.Filter.lt('windspeed',3.0))  //select only wind speeds < 3 m/s
.map(function(image){
var yyyymmdd = ee.String(image.get('system:index')).slice(0,8) //slice date: only yyyymmdd left
return image.set('date', yyyymmdd)
});

Export.table.toDrive({
collection: ERA5x.sort('windspeed'),
description: 'NL_mean_wind',
selectors: ['date', 'windspeed', 'winddir']
});
``````

``````var ERA5total = innerJoin.apply(ERA5meanspeed, ERA5meandir, filter)