I want to download the shapefile of an area in GEE tool/application, It is getting printed in the console but not able to download it using the label. I tried this by using the following answer to the similar question for images, you can check this as well, if required https://gis.stackexchange.com/a/344726/221102
// Define a panel
var mainPanel = ui.Panel({
style: {width: '150px'}
});
//title to be shown
var title = ui.Label({
value: 'Brahamaputra Islands',
style: {'fontSize': '24px'}
});
///////define a variable with button and add the whole process as function in it//////////////////
var load = ui.Button('Load Islands');
load.onClick(function() {
mainPanel.clear() // .remove() for a single layer and .clear for all panel
var ed=ee.Date(Date.now());
var eb=ed.advance(ee.Number(-35),'day')
///////////////// Dynamic World ////////////////////////
var dw = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterDate(eb, ed)
.filterBounds(geometry);
var img= ee.Image('GOOGLE/DYNAMICWORLD/V1/20230531T042711_20230531T043753_T46RCP');
// Select label layer
var classification = dw.select('label');
var dwComposite = classification.reduce(ee.Reducer.mode());
var water = dwComposite.eq(0);
////////////////////////////////masking//////////////////////////////
water=water.selfMask().clip(geometry)
print(water,"water")
var bandNames = dwComposite.bandNames();
print('dwComposite Band names:', bandNames);
var mask = dwComposite.select('label_mode').eq(0);
var nw = mask.updateMask(dwComposite).clip(geometry)
// Convert to vectors.
var vector = nw.reduceToVectors({
geometry: geometry,
crs: water.projection(),
scale: 10,
maxPixels: 1e13,
geometryType: 'polygon',
eightConnected: false, // it takes4connectedpixels if false
labelProperty: 'zone',
reducer: ee.Reducer.countEvery()
});
// Add area property to dissolved features(non water).
var addArea = function(feature) {
return feature.set({areaSqKm: feature.geometry().area(1).divide(10e6)});
};
var areaAdded = vector.map(addArea);
////////////////FILTER AREA/////////////////////////////////////////////////////////////////////////////
var Area = areaAdded.filter(ee.Filter.and(
ee.Filter.gte('areaSqKm', 0.0001),
ee.Filter.lte('areaSqKm', 3.5)
));
// Export to Drive.
Export.table.toDrive({
collection: areaAdded,
description: 'non_water_vector',
folder: 'missingvalues_hold',
fileFormat: 'SHP',
maxVertices: 1000000000
});
// Get a download URL for the FeatureCollection.
var downloadUrl = Area.getDownloadURL({
format: 'CSV',
filename: 'Islands'
});
print('URL for downloading FeatureCollection as CSV', downloadUrl);
var label= ui.Label
label.setUrl(downloadUrl);
label.style().set({shown: true});
// Add UI elements to the Map.
var downloadButton = ui.Button('Download viewport', downloadUrl);
var urlLabel = ui.Label('Download', {shown: false});
var panel = ui.Panel([downloadButton, urlLabel]);
Map.add(panel);
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//add widgets to the panel
mainPanel.add(title)
mainPanel.add(load);
ui.root.add(mainPanel);
Map.setCenter(91.3021, 26.1741,12)
here is the link to my code. https://code.earthengine.google.com/5b79b9e77630be0ffe1d8ebc2acd3da6
Please help me regarding this.