I am running several thousand polygons through a Google Earth Engine code and many of them have names with spaces in them and when I try to run the initiate image export I get "Task name may contain alphanumeric characters, underscores, and dashes. No spaces." It would be impractical for me to go through and add and underscore to them in the attribute table.
So in this one case I am trying to run a fire with the name Flying R. In the attribute table it has a space in the name so it will not successfully run. Is there a way I can code it so that it will automatically insert an "_" wherever there is a " "?
This is the code I though would be relevant. Let me know if you need more.
var fires = ee.FeatureCollection("users/mtd25/fires/AZ3143311069520170614_FLYING_R");
.
.
var fireID = ee.List(fires.aggregate_array('Fire_ID')).getInfo();
print(fireID)
var nFires = fireID.length;
var Fire_Name = ee.List(fires.aggregate_array('Fire_Name')).getInfo(); //For Megan's dataset
.
.
for (var j = 0; j < nFires; j++){
var id = fireID[j];
var Name = id;
var fireExport = ee.Image(indices.filterMetadata('fireID', 'equals', id).first());
var fireBounds = ee.Feature(fires.filterMetadata('Fire_ID', 'equals', id).first()).geometry().bounds();
for (var i = 0; i < nBands; i++) {
var bandExport = bandList[i];
var exportImg = fireExport.select(bandExport);
Export.image.toDrive({
image: exportImg,
description: Name + '_' + Fire_Name + '_' + bandExport,
fileNamePrefix: Name + '_' + Fire_Name + '_' + bandExport,
maxPixels: 1e13,
scale: 30,
crs: "EPSG:4326",
folder: 'fires',
region: fireBounds