Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to batch export VIIRS images to Google Drive #74

Closed
nikosGeography opened this issue Sep 18, 2022 · 3 comments
Closed

Comments

@nikosGeography
Copy link

nikosGeography commented Sep 18, 2022

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 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')
  .first()
  .clip(table);
  
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});

The table is a polygon shp that I am using to clip the area of interest. The same error occurs even if I specify a bounding box using ee.Geometry.
Here is a link to the GEE project

@nikosGeography nikosGeography changed the title Error when using trying to batch export VIIRS images to Google Drive Error when trying to batch export VIIRS images to Google Drive Sep 18, 2022
@acwatt
Copy link

acwatt commented Nov 7, 2023

Related: fitoprincipe/geetools-code-editor#13

@12rambau
Copy link
Member

12rambau commented Nov 7, 2023

I agree with @acwatt in the other thread your object is not an imageCollection anymore as you specified .first(), as a consequence it has no size.

@nikosGeography
Copy link
Author

The solution is:

//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});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants