I am quite new to Google Earth Engine.
I am trying to export a VIIRS night-time light image with an attribute table attached (displaying the mean, median etc) which is also clipped to India (I am using a shapefile). I am completely lost when it comes to exporting the image and attributes.
Below is my code so far:
var variable = 'NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG';
var region = ee.FeatureCollection("users/user/india_adm").geometry();
var start_date = '2018-01-01';
var finish_date = '2018-12-31';
var bands = 'avg_rad';
var image = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG');
// Load input imagery. NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG
var dataset = ee.ImageCollection(variable)
.filterDate(start_date, finish_date)
.select(bands)
.filterBounds(region);
// Convert the layer
dataset = dataset.map(function(img){
var date = img.get('system:time_start');
return img.set('system_time_start', date);
});
// Create a function that takes an image, calculates the mean over a geometry and returns the value and the corresponding date as a feature.
var createData = function(img){
var date = img.get('system_time_start');
var valueMean = img.reduceRegion({reducer: ee.Reducer.mean(), geometry: region, scale: 30, maxPixels: 16016779});
var valueSum = img.reduceRegion({reducer: ee.Reducer.sum(), geometry: region, scale: 30, maxPixels: 16016779});
var valueMedian = img.reduceRegion({reducer: ee.Reducer.median(), geometry: region, scale: 30, maxPixels: 16016779});
var valueStdDev = img.reduceRegion({reducer: ee.Reducer.stdDev(), geometry: region, scale: 30, maxPixels: 16016779});
var valueVariance = img.reduceRegion({reducer: ee.Reducer.variance(), geometry: region, scale: 30, maxPixels: 16016779});
var ft = ee.Feature(null, {'system:time_start': date,
'date': ee.Date(date).format('Y/M/d'),
'Mean': valueMean.get('avg_rad'),
'Sum': valueSum.get('avg_rad'),
'Median': valueMedian.get('avg_rad'),
'stdDev': valueStdDev.get('avg_rad'),
'Variance': valueVariance.get('avg_rad'),
});
return ft;
};
// Apply the function to each image in dataset
var serie = dataset.map(createData);
var collection = ee.ImageCollection(variable)
.filterDate(start_date, finish_date)
.select(bands)
.filterBounds(region);
var composite = collection.reduce(ee.Reducer.sum());
var canny = ee.Algorithms.CannyEdgeDetector({
image: composite, threshold: 100, sigma: 1
});
var nighttimeVis = {min: 0.0, max: 60.0};
print('composite', composite);
Map.setCenter(78.40263161385201, 21.17558399803013, 4.5);
Map.addLayer(composite.clip(region),{min:0,max:60.0,bands:"avg_rad_sum"});