Coder Social home page Coder Social logo

fitoprincipe / geetools-code-editor Goto Github PK

View Code? Open in Web Editor NEW
298.0 17.0 109.0 947 KB

A set of tools to use in Google Earth Engine Code Editor (JavaScript)

Home Page: https://github.com/fitoprincipe/geetools-code-editor/wiki

License: MIT License

google-earth-engine javascript satellite-imagery remote-sensing

geetools-code-editor's Introduction

A set of tools to use in Google Earth Engine Code Editor

Google Earth Engine is a web platform for satellite image processing (https://earthengine.google.com/). One way to use this platform (probably the most popular way) is using an online tool called The Code Editor, which let the user access the platform using a scripting language (JavaScript).

Documentation and examples in the Wiki Page

geetools-code-editor's People

Contributors

fitoprincipe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geetools-code-editor's Issues

geetools:cloud_masks not running with Landsat new collections

When using the Landsat datasets now, they ask to migrate the workflows from Landsat Collection 1 to Collection 2. I think they have changed the name of some bands or terms, and this is why the "cloud_maks" function is not working anymore.
In my code it works for "ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')" but not in "ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")"
I think these terms are the only things that need to be changed.
https://www.usgs.gov/landsat-missions/landsat-collection-2-level-2-science-products
Could you check this?
Thanks a lot,
Ivan

Export image collection to asset

I am trying to export a collection of Landsat 8 images as assets but keep getting a geometry error. I originally was performing a number of operations to the scenes once selected from the landsat collection and thought maybe the geometry was getting altered in the process. In the code below, I tried to simplify the process so that the final image collection represents the least cloudy Landsat 8 scene over a selection of watersheds in Montana, during the 2018growing season, but the error still occurs.

Thanks in advance for the help and I appreciate the tools you have put together!

var huc8 = ee.FeatureCollection("USGS/WBD/2017/HUC08")

var mt = ee.FeatureCollection("TIGER/2018/States").filter(ee.Filter.equals('NAME', 'Montana'));
// Map.addLayer(mt)

var sheds = huc8.filterBounds(mt).filter(ee.Filter.or(ee.Filter.equals('name','Peoples'), ee.Filter.eq('name','Belt'), ee.Filter.eq('name','Arrow')));

// var sheds = ee.FeatureCollection('users/ryanpatrickrock/bpHuc_testData')

print(sheds);

var testFun = function(feature){
  
  var ROI = feature.geometry();
  
  var addCloud = function(image) {
    var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
    var cloudiness = cloud.reduceRegion({ // calculate average cloud score across the ROI i.e the watershed specified
      reducer: 'mean', 
      geometry: ROI, 
      scale: 30,
      maxPixels: 1e12
    });
  return image.set(cloudiness); // add this cloud score to the metadata of the image
  };
  
  var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")
        .filterDate('2018-05-15', '2018-09-15')
        .filterBounds(ROI)
        .map(addCloud)
        .sort('cloud')

  var scene = l8.first()
                .select(['B1','B2','B3','B4','B5','B6','B7'])
                .clip(ROI)
  return scene
};

var sceneCol = ee.ImageCollection(sheds.map(testFun));
print(sceneCol)

Map.addLayer(sceneCol, {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.5})

Map.addLayer(sceneCol.first().geometry().bounds())

print(sceneCol.first().geometry().bounds())

var batch = require('users/fitoprincipe/geetools:batch');

batch.Download.ImageCollection.toAsset(sceneCol, 'users/ryanpatrickrock', {
  name: 'test_batchCollection',
  scale: 30,
  region: null,
  maxPixels: 1e12
  }
);

String: Unable to convert object to string. Predicted pH: Layer error: String: Unable to convert object to string.

Hi People,
I'm trying to model some soil parameters using random forest in google earth engine. However I am having a problem going past this error code in my work: Number (Error)
String: Unable to convert object to string. Predicted pH: Layer error: String: Unable to convert object to string.
Kindly assist.

This is my code:
// Define the study area boundary using your shapefile
var studyArea = ee.FeatureCollection('projects/ee-evanomondi/assets/Study_area');

// Load the pH and CaCO3 data from your shapefile
var soilData = ee.FeatureCollection('projects/ee-evanomondi/assets/Data_Points2');

// Load the Sentinel-1 SAR, Digital Elevation Model, and climatic data for 2018
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD_FLOAT')
.filterDate('2018-01-01', '2018-12-31')
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.median();

// Load the Digital Elevation Model (DEM) data
var dem = ee.Image('USGS/SRTMGL1_003');

// Print the DEM image object
print('DEM:', dem);

// Visualize the DEM
var demVis = {
min: 0,
max: 4000,
palette: ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']
};
Map.addLayer(dem, demVis, 'DEM');

// Optional: Center the map on the DEM
Map.centerObject(dem, 10);

// Assign the DEM data to the 'dem' variable
var dem = ee.Image('CGIAR/SRTM90_V4');

// Define the date range for the CHIRPS data
var startDate = '2018-01-01';
var endDate = '2018-12-31';

// Load the CHIRPS precipitation data for the specified date range
var chirps = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterDate(startDate, endDate)
.select('precipitation')
.sum();

// Print the CHIRPS image object
print('CHIRPS Data:', chirps);

// Visualize the precipitation
var precipitationVis = {
min: 0,
max: 200,
palette: ['white', 'lightblue', 'blue', 'purple', 'pink']
};
Map.addLayer(chirps, precipitationVis, 'Precipitation');

// Optional: Center the map on the CHIRPS data
Map.centerObject(chirps, 6);

// Assign the CHIRPS data to the climaticData variable and use the correct band name
var climaticData = chirps.select('precipitation');

// Prepare the training data by combining the soil data with the auxiliary variables
var trainingData = soilData.map(function(feature) {
var point = feature.geometry();
var pH = feature.getNumber('pH');
var CaCO3 = feature.getNumber('CaCO3');

var sentinel1Values = sentinel1.sampleRegions({
collection: ee.FeatureCollection(point),
scale: 10,
tileScale: 16
}).first();

var demValue = dem.reduceRegion({
reducer: ee.Reducer.first(),
geometry: point,
scale: 10,
maxPixels: 1e9
}).get('elevation');

var climaticDataValue = climaticData.reduceRegion({
reducer: ee.Reducer.first(),
geometry: point,
scale: 10,
maxPixels: 1e9
}).get('precipitation');

return ee.Feature(point, {
pH: pH,
CaCO3: CaCO3,
sentinel1: sentinel1Values,
dem: demValue,
climaticData: climaticDataValue
});
});

// Split the training data into training and validation sets
var split = 0.7; // Change this value to adjust the split ratio
var randomSeed = 123; // Change this value to set a specific random seed for reproducibility
var trainingSet = trainingData.randomColumn('random', randomSeed).filter(ee.Filter.lt('random', split));
var validationSet = trainingData.randomColumn('random', randomSeed).filter(ee.Filter.gte('random', split));

// Prepare the training features and target
var features = ee.List(['sentinel1', 'dem', 'climaticData']);
var target = 'pH'; // Change this to 'CaCO3' for modeling CaCO3

var trainingFeatures = trainingSet.map(function(feature) {
var values = ee.Image(feature.get('sentinel1')).sampleRegions({
collection: ee.FeatureCollection(feature.geometry()),
scale: 10,
tileScale: 16
});
return feature.set('sentinel1', values);
});

var trainingFeaturesArray = trainingFeatures.aggregate_array(features.slice(0, features.size()));

trainingFeaturesArray = ee.Array(trainingFeaturesArray).toList().map(function(row) {
return ee.Feature(null, ee.Dictionary.fromLists(features, row));
});

var trainingFeatures = ee.FeatureCollection(trainingFeaturesArray);
var trainingTarget = trainingSet.select(target);

// Prepare the validation features and target
var validationFeaturesList = validationSet.map(function(feature) {
var values = ee.Image(feature.get('sentinel1')).sampleRegions({
collection: ee.FeatureCollection(feature.geometry()),
scale: 10,
tileScale: 16
});
return feature.set('sentinel1', values);
});

var validationFeaturesArray = validationFeaturesList.aggregate_array(features.slice(0, features.size()));

validationFeaturesArray = ee.Array(validationFeaturesArray).toList().map(function(row) {
return ee.Feature(null, ee.Dictionary.fromLists(features, row));
});

var validationFeatures = ee.FeatureCollection(validationFeaturesArray);
var validationTarget = validationSet.select(target);

// Train the model using a Random Forest algorithm
var nTrees = 100; // Change this value to adjust the number of trees in the model
var rf = ee.Classifier.smileRandomForest({
numberOfTrees: nTrees,
variablesPerSplit: 0,
bagFraction: 0.5,
seed: randomSeed
}).train({
features: trainingFeatures,
classProperty: target,
inputProperties: features
});

// Make predictions on the validation set
var validationPredictions = validationFeatures.map(function(feature) {
var prediction = ee.Image(rf).classify(feature);
return feature.set('prediction', prediction);
});

// Compute the confusion matrix for the validation set
var validationAccuracy = ee.ConfusionMatrix(validationPredictions.aggregate_array(target), validationPredictions.aggregate_array('prediction'));

// Print the validation accuracy
print('Validation Accuracy:', validationAccuracy.accuracy());

// Visualize the predicted pH values
var pHVis = {
min: 0,
max: 14,
palette: ['red', 'yellow', 'green']
};
Map.addLayer(validationPredictions.select(['prediction']), pHVis, 'Predicted pH');

// Optional: Center the map on the study area
Map.centerObject(studyArea, 8);

// Define a function to export the pH prediction map
var exportMap = function() {
// Make predictions on the entire study area
var studyAreaFeatures = studyArea.map(function(feature) {
var values = ee.Image(sentinel1).sampleRegions({
collection: eeCollection(feature.geometry()),
scale: 10,
tileScale: 16
});
return feature.set('sentinel1', values);
});

var studyAreaFeaturesArray = studyAreaFeatures.aggregate_array(features.slice(0, features.size()));

studyAreaFeaturesArray = ee.Array(studyAreaFeaturesArray).toList().map(function(row) {
return ee.Feature(null, ee.Dictionary.fromLists(features, row));
});

studyAreaFeatures = ee.FeatureCollection(studyAreaFeaturesArray);

var predictionMap = studyAreaFeatures.map(function(feature) {
var prediction = ee.Image(rf).classify(feature);
return feature.geometry().set('prediction', prediction);
});

// Export the prediction map as a GeoTIFF file to your Google Drive
Export.image.toDrive({
image: predictionMap.select(['prediction']),
description: 'pH_prediction_map',
folder: 'GEE_Project',
scale: 10,
region: studyArea.geometry()
});
};

error with "Download.ImageCollection.toDrive"

Hello, thanks for your useful code. I'm exporting an image collection to drive using your code. But I encountered an error when I try to use name in the parameter options. Here is my code:

var areaName = "defaultexportArea" //"SDN2";  // name of ROI
var startDate = '2020-05-01';
var endDate = '2020-10-01';
var exportFolder = 'GEEdownload_bd';

var exportArea = ee.Geometry.Polygon([
    [28.98855495720401,0.9531234556460979],
    [29.32913112907901,0.9531234556460979],
    [29.32913112907901,0.6949716650615738],
    [28.98855495720401,0.6949716650615738],
    [28.98855495720401,0.9531234556460979]]);

var dwCollection = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
    .filterDate(startDate, endDate)
    .filterBounds(exportArea)


var exportOptions = ee.Dictionary({
  scale: 10, 
  region: exportArea, 
  type: 'float',
  name: 'dw_{id}'
});

var batchExport = require('users/fitoprincipe/geetools:batch').Download.ImageCollection.toDrive;
batchExport(dwCollection, exportFolder + '-' + 'dynamic_world', exportOptions);

where exportArea is a polygon. It raise this error:

"Invalid argument specified for ee.String(): function(){var d=Ga.apply(0,arguments).map(function(e){return c.er(e)});d=XSa(c,a,d);return c.lj(d)}"

Is there anything wrong in my script?

Unable to export multiple images

Hi,

I want to export multiple images but unfortunately, while trying to run batch.Download.ImageCollection.toDrive, all the images were corrupted (blank with some kind of noise).

After not successfully implementing your example, I tried to write the for loop as you did with slight modification. Namely, the problem I am trying to solve is to select different regions on the same image.

For every selected point, I run expandToSquare:

var expandToSquare = function(point) {
  return ee.Geometry.Point(point).buffer(10).bounds()
}

so this is the list of squares:

var samplePoints = samples.coordinates();
var sampleSquares = samplePoints.map(expandToSquare);

For a single image, the following example works fine (export the neighborhood of 3rd point from the list):

Export.image.toDrive({
    image: drone_image_unscaled,
    description: 'test',
    scale: 0.1,
    region: sampleSquares.get(2)
  });

If I try to run the following, none of the tasks appears:

var samplesCount = sampleSquares.size();
for (var i = 0; i < samplesCount; i++) {
xport.image.toDrive({
    image: drone_image_unscaled,
    description: i,
    scale: 0.1,
    region: sampleSquares.get(i)
  });
}

I would be thankful if you could provide a suggestion either how to implement for loop or how to create a collection of images, suitable to use your library, after selecting various regions of the same underlying image.

Here is the link to my current implementation

And this is the screenshot of the problem I am trying to solve (select multiple samples of the image and save them to separate images):
image

GEE image does not display after applying the cloud mask based on SCL band

I am new in GEE and I want to work on NDVI time series, but before doing this I want to preprocess Sentinel-2A images using a cloud mask based on Scene Classification (SCL) band.

The code bellow imports three types of masks, apply one of them and visualize the image before and after applying the mask.

My question is that when I use Mask2 or Mask3, the image after applying the mask does not display. However, Mask1 works perfectly!

Here is the link to the code in GEE: https://code.earthengine.google.com/429990239fd25488aa9614bc87685385

Please, I need your help to solve this issue.
`
var cld = require('users/fitoprincipe/geetools:cloud_masks');

var col = ee.ImageCollection('COPERNICUS/S2_SR');

var img = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2018-04-01', '2018-04-30')
.median().select('TCI_R','TCI_G','TCI_B');
print('img', img);
Map.addLayer(img);

// Mask useless classes from built-in Scene Classification
var Mask1 = function(image) {
var masked = cld.sentinel2(['opaque', 'cirrus'])(image)
return masked
}

var Mask2 = function(image) {
var masked = cld.sclMask(['cloud_low', 'cloud_medium',
'cloud_high', 'cirrus', 'shadow', 'saturated', 'dark',
'snow'])(image)
return masked
}

var Mask3 = function(image) {
var masked = cld.hollstein_S2(['cloud', 'snow', 'shadow', 'water', 'cirrus'])(image)
return masked
}

// Apply the mask
var Masked_col = col.map(Mask2);
var msk_img = Masked_col.filterDate('2018-04-01', '2018-04-30')
.median().select('TCI_R','TCI_G','TCI_B');
print('masked img', msk_img);
Map.addLayer(msk_img);
`

Invalid GeoJSON geometry error when trying to batch download

I receive an error when executing the following script:

var batch = require('users/fitoprincipe/geetools:batch')
var col = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR").filterDate("2002-01-01","2002-01-03");
batch.Download.ImageCollection.toDrive(col, "Folder", {scale:30});

Invalid GeoJSON geometry: [[[-73.87879425086899,46.471905677908346],[-70.84547603387989,46.471905677908346],[-70.84547603387989,48.4283626121078],[-73.87879425086899,48.4283626121078],[-73.87879425086899,46.471905677908346]]]

Why is this occurring?

String: Unable to convert object to string.

Dears,

I'm have a problem applying the function batch to download an image collection of Sentinel-1 satellite. With this code:

`var roi = ee.FeatureCollection('ft:16UGb-zfZNV_Nc2-YQyWs9tzPZgkeXBeCgi9ke51Q');

//Criando a variável, como coleção, para armazenar as cenas filtradas:
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))
.filterBounds(roi)
.filterDate('2019-08-01', '2019-08-31');

var S1 = sentinel1.select(['VV', 'VH']);

//Exibindo no Console os produtos encontrados:
print(S1);

//Exibindo no mapa o vetor e as cenas:
Map.centerObject(roi, 7.5)
Map.addLayer(S1,{bands:['VH'], min: -20, max: 5})

//Exportando coleção para o drive:
var batch = require('users/fitoprincipe/geetools:batch')
batch.Download.ImageCollection.toDrive(S1, "S1", {scale: 10, region:roi})`

Result in this error and the images aren't downloaded in google drive:
"String: Unable to convert object to string."

Follows the link to my code in GEE:
https://code.earthengine.google.com/9bab8775a744cb30fa347e2d8a6e6126

Thank you by attention!
My bests regards.

Regarding geetools (cloud masks)

Hi,
I am using your geetool for cloud masking but its not working for Landsat 8 Collection 2 images.
Could you please guide me because I need to mask out cloud.
Here is the code ---
var cloud_masks = require('users/fitoprincipe/geetools:cloud_masks');
var landsatSRfunction = cloud_masks.landsatSR;

// The original Image
var L8Image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_140046_20200115');

// Apply mask
var masked_image = landsatSRfunction()(L8Image);

// Visualize
var vis = {bands:['SR_B5', 'SR_B7', 'SR_B4'], min:0, max:30000}
Map.addLayer(masked_image, vis, 'Landsat 8 SR masked');
Map.centerObject(masked_image)

difference from cloudmask in ee

Hi,Rodrigo
I want to know the difference between the landsat cloud mask part and the official website of gee, I found that he kept more information. Can you tell me why?
Sorry,I am not very proficient in code.

Issue with batch encountering error

Hi, I was trying to use batch.ImageCollection.toDrive and I received the error:

Cannot read property 'toDrive' of undefined

I tried running the code directly from source and it only worked when I changed the region parameter to null in Export.Image.toDrive and exported only img instead of imgType. Do you know why the error occurred?

Here is my code with the failure:

var xmin = 97.1286789065688
var xmax = 97.4294562866087
var ymin = 24.7742991886781
var ymax = 24.9930169846125

var polygon = ee.Geometry.Polygon([
  [xmin, ymin], [xmin, ymax],
  [xmax, ymax], [xmax, ymin]
]);

Map.addLayer(polygon);
Map.centerObject(polygon, 8);

var collection = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
                .filterDate("2015-06-23", "2020-02-01")
                .filterBounds(polygon)

var clipped = collection.map(function(img){
  return img.clip(polygon)
})
//print(clipped)

var batch = require('users/fitoprincipe/geetools:batch');
batch.ImageCollection.toDrive(clipped, 'imagesL8app', {scale: 30, type: 'uint16'})

And here is the source code I used that worked:

var tools = require('users/fitoprincipe/geetools:tools');    
var downloadAll = function(collection, folder, options) {
    
    var defaults = {
      scale: 1000,
      maxPixels: 1e13,
      type: 'float',
      region: null,
      name: null,
    }
    
    var opt = tools.get_options(defaults, options)
    
    var n = collection.size().getInfo();
    
    var colList = collection.toList(n);
    
    var colID = opt.name || collection.getInfo()['id'] || ""
    colID = colID.replace('/','_')
    
    for (var i = 0; i < n; i++) {
      var img = ee.Image(colList.get(i));
      var id = img.id().getInfo() || colID+'_image_'+i.toString();
      var region = opt.region || img.geometry().bounds().getInfo()["coordinates"];
      
      //var imtype = IMAGE_TYPES(img, opt.type)
      
      Export.image.toDrive({
        image: img,
        description: id,
        folder: folder,
        //region: region,
        fileNamePrefix: id,
        scale: opt.scale,
        maxPixels: opt.maxPixels})
    }
  }
downloadAll(clipped, 'imagesL8app', {scale: 30, type: 'uint16'})

Error when using trying to batch export VIIRS images to Google Drive

Hi, I was trying to use batch.ImageCollection.toDrive and I received the error:

In users/fitoprincipe/geetools:batch
Line 133: collection.size is not a function

Here is my code:

var batch = require('users/fitoprincipe/geetools:batch')
// Load the VIIRS ImageCollection.
var dataset = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG')
.filterBounds(table)
.select('avg_rad')
.first()
.clip(table);
batch.Download.ImageCollection.toDrive(dataset, 'Folder',
{scale: 460,
region: (table),
type: 'float'})

The table is a shp that I use to clip the ImageCollention. The same error appears when using a bounding box. I created a folder called Folder in my Google Drive.
Here is the link to the GEE project.

Time Series Prediction of CEEI

// Define the feature names (modify as needed)
var features = ['Excellent', 'Good', 'Moderate', 'Fair', 'Poor'];

// Define the image collections with a list (replace with your actual collections)
var imageCollections = [ceei2003, ceei2011, ceei2023];

// Function to create a single image collection with bands from each year
function combineCollections(image) {
var year = image.date().format('YYYY');
return image.select(features).rename(features.map(function(f) { return f + '_' + year; }));
}

// Combine image collections into a single one with renamed bands
var imageCollection = ee.ImageCollection(imageCollections).map(combineCollections);

// Function to add year as a feature
function addYear(image) {
var date = image.date();
var years = date.difference(ee.Date('1970-01-01'), 'year');
return image.addBands(years);
}

// Apply functions and filter to your area of interest
var imageCollection = imageCollection
.map(addYear)
.filterBounds(your_geometry); // Replace with your area of interest geometry

// Define Random Forest training data (modify as needed)
var trainingData = imageCollection.filterDate('2003-01-01', '2011-12-31'); // Adjust training period

// Function to define a Random Forest classifier (adjusted for API compatibility)
function classify(image) {
var trainingFeatures = trainingData.select(features.concat(['year']));
var trainingLabels = trainingData.select('classification'); // Replace 'classification' with your actual label band

var classifier = ee.Classifier.smileRandomForest({
numberOfTrees: 100 // Adjust number of trees
});

return image.select(features.concat(['year']))
.classify(classifier.train(trainingFeatures, trainingLabels));
}

// Apply Random Forest classification
var classifiedCollection = imageCollection.map(classify);

// Function to predict future year (modify year as needed)
function predict(classifiedImage, year) {
// Set the predicted year as a property to the classified image
return ee.Image(classifiedImage).set('predicted_year', year);
}

// Predict for a future year (replace 2025 with your desired year)
var predictedImage = classifiedCollection.map(predict.bind(null, 2025));

// Select the first image from the predicted collection
var predictedImageFirst = predictedImage.first();
// Predict for a future year (replace 2025 with your desired year)
var predictedImage = classifiedCollection.map(predict.bind(null, 2025));

print(predictedImageFirst);

// // Add the predicted image to the map
// Map.addLayer(predictedImageFirst, {bands: ['Excellent_2025', 'Good_2025', 'Moderate_2025'], min: 0, max: 1, gamma: 1.4}, 'Predicted Image');

// // Display the map
// Map.centerObject(your_geometry, 10); // Center the map on your geometry
// // Map.addLayer(your_geometry, {}, 'Area of Interest'); // Add a layer for visualization

Link: https://code.earthengine.google.com/bbf8cde3b66c29678ee60279f35d0230

when i run the code it shows
Image (Error)
String: Unable to convert object to string. Please help

problem exporting imageCollection to drive

Hi Rodrigo,

Thank you for providing these GEE tools!

Im trying to export an image collection from GEE to drive, or cloud storage, using your code (batch).
Im getting this error:

In users/fitoprincipe/geetools:batch
Line 133: collection.size is not a function

Do you know how can I solve this? My code below:

var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
   .filterBounds(studyArea).filterDate('2019-01-01', '2019-12-31')
   .filterMetadata('CLOUD_COVER', 'less_than', 30);
print(collection)

var batch = require('users/fitoprincipe/geetools:batch')
var count = collection.size()
print("Coleccion", count)

// Export the image, specifying scale and region.
 batch.Download.ImageCollection.toDrive({
   image: collection,
   description: 'imageCollection_L8_2019',
   scale: 30,
   region: studyArea,
   fileFormat: 'GeoTIFF',
   formatOptions: {
    cloudOptimized: true
  }
 });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.