0

I am trying to export all images of the image collection of VIIRS. I am following the answer from this post. Instead of setting a bounding box as a clipping layer I have a .shp of my study area. When I run the code I am receiving this error:

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

Here is the 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'})

Why that error? I believe I am following exactly the steps like others did and when I download a single monthly image I do not have any issue.

4
  • You excluded the line of code actually generating the error, there is a problem with your use of .size() not the image exporting
    – M. Nicolas
    Sep 20 at 18:26
  • I didn't exclude it, it's the first code chunk (var batch =....)
    – Nikos
    Sep 20 at 18:38
  • Your error is marked line 133 within the script you are requiring, clearly there are not 133 lines here nor is there a size function so yes it is excluded.
    – M. Nicolas
    Sep 21 at 16:44
  • in the beginning of my script I am calling a function (var batch = require('users/fitoprincipe/geetools:batch')). This function can be found here (github.com/fitoprincipe/geetools-code-editor/wiki/…). Also, I mention in my post, what steps I am following (please refer to the link in my question). My code doesn't have 133 lines of code so the issue is probably with the function I am calling although other people seems to not having an issue with the function.
    – Nikos
    Sep 21 at 16:56

1 Answer 1

1

There is no problem with Principe's code. Here is the solution:

//var table = ee.FeatureCollection("users/nikostziokas/manchester");
var batch = require('users/fitoprincipe/geetools:batch')

// Load Landsat 8 imagery and filter it  
var collection = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG')
  .filter(ee.Filter.date('2013-05-01', '2021-12-31'))
  .filterBounds(table)
  .select('avg_rad')
/* from here I was transforming the collection into an Image
  .first()
  .clip(table); // clip is an ee.Image method
*/
  
var count = collection.size()
print("Collection", count)

// export collection to google drive
batch.Download.ImageCollection.toDrive(
  collection, 
 'Folder', 
  {name: 'ntl_{system:index}',
  crs: 'EPSG: 27700',
  type: 'float',
  scale: 460,
  region: table});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.