I've built an app that displays an image. I want the user of the app to be able to download the data from the viewport in a GeoTIFF format for further use in GIS.
I've got my export function running on the developer side and can download the data via the Tasks pane as per instructions. But is there a way to open this download up for the external user? I'm starting to fear not….
Here is the relevant code that creates/adds a button to execute the export function.
// Export data function
var exportData = function(range) {
print("Exporting data...")
Export.image.toDrive({
image: ndvi,
description: 'imageToDriveExample',
folder: "GEE_Exports",
fileNamePrefix: "NDVI",
dimensions: "10000x10000",
scale: 30,
shardSize: 100,
fileDimensions: 1000,
fileFormat: "GeoTIFF"
//maxPixels: 1e12
});
}
//...add update map button to panel
var exportDataButton = new ui.Button({
label: 'Export Data',
//style: {stretch: 'horizontal'}
});
// Register the function to the button click event.
exportDataButton.onClick(exportData);
// Add to button panel
buttPanel.add(exportDataButton);
If this is possible, will I need a cloud account?
Best Answer
You can use the
getDownloadURL()
image method to print a download URL to aui.Label
element. The following snippet is a complete example. Note that this should only be used to download small regions, it is not intended for large-scale data distribution applications.Code Editor link