I am trying to use the MODIS Terra Thermal Anomalies & Fire Daily Global dataset to get fire data in a date range at random points. I have the following code:

var dataset = ee.ImageCollection('MODIS/006/MOD14A1')
                  .filter(ee.Filter.date('2018-01-17', '2019-01-04'));

var fireMaskVis = {
  min: 0.0,
  max: 6000.0,
  bands: ['MaxFRP', 'FireMask', 'FireMask'],
Map.setCenter(6.746, 46.529, 2);
Map.addLayer(dataset, fireMaskVis, 'Fire Mask');

// coordinates to zoom to and get statistics from
var AOI = ee.Geometry.Polygon(
AOI = ee.FeatureCollection.randomPoints(AOI);
var point = ee.Geometry.Point([2.3622940161999395, 42.569280018996714]);
Map.addLayer(AOI, {}, 'the area of interest');
Map.centerObject(AOI, 11);

var fire = dataset.select("FireMask");

// reduce the surface temperature image collection to a single image with stacked bands
function collToBands(imageCollection, bandName) {
  // stack all the bands to one single image
  // change the name of the bandname to the date it is acquired
  var changedNames = imageCollection.map( function(img){ 
    var dateString = ee.Date(img.get('system:time_start')).format('yyyy-MM-dd');
    return img.select(bandName).rename(dateString);

  // Apply the function toBands() on the image collection to set all bands into one image
  var multiband = changedNames.toBands();
  // Reset the bandnames
  var names = multiband.bandNames();
  // rename the bandnames 
  var newNames = names.map(function(name){
    var ind = names.indexOf(name);
    return ee.String(names.get(ind)).slice(5);
  return multiband.rename(newNames);
// apply the function and print to console
var multiband = collToBands(fire, "FireMask");
//print('collection to bands', multiband);

// get the temperature at a given point on the map for the given time spand and print to the console
var firePoint = multiband.reduceRegion({reducer: ee.Reducer.mean(), geometry: point, scale: 1000, bestEffort: true});


// make a feature collection of many pixelsize-spaced points
function spacedPoints(AOI, proj) {
  // make a coordinate image
  // get coordinates image
  var latlon = ee.Image.pixelLonLat().reproject(proj);
  // put each lon lat in a list -> this time for getting an multipoint list (more useful inside the GEE)
  var coords = latlon.select(['longitude', 'latitude'])
                 .reduceRegion({reducer: ee.Reducer.toList(),
                                geometry: AOI,
                                scale: proj.nominalScale().toInt()
  // zip the coordinates for representation. Example: zip([1, 3],[2, 4]) --> [[1, 2], [3,4]]
  var point_list = ee.List(coords.get('longitude')).zip(ee.List(coords.get('latitude')));
  // preset a random list
  var list = ee.List([0]);
  // Make a feature collection of the multipoints and assign distinct IDs to every feature
  var feats = ee.FeatureCollection(point_list.map(function(point){
    var ind = point_list.indexOf(point);
    var feat = ee.Feature(ee.Geometry.Point(point_list.get(ind)), {'ID': ind});
    return list.add(feat);
  return feats;
// use function to get the spaced points
var points = spacedPoints(AOI, multiband.projection());
// add to the map
Map.addLayer(points.draw('red'), {}, 'the spaced points');

// calculate the temperature over the time span at every point in the AOI
var fires = multiband.reduceRegions({collection: points, reducer: ee.Reducer.mean(), scale: 1000});
//print('feature collection of temperatures', temperatures);
//print(fires.filter(ee.Filter.eq("system:index", '0')));

var aDate = ee.Date('2018-01-17');
var days = ee.List.sequence(0, 352); //352
var dates = days.map(function(d) {
  return aDate.advance(ee.Number(d), 'day').format('YYYY-MM-dd');


var pointCounts = [];
for(var e = 0; e < 100; e++) {

var pointValues = pointCounts.map(function(point) {
  var numOfDates = ee.List.sequence(0, 10);
  var values = numOfDates.map(function(i) {
    return fires.filter(ee.Filter.eq("system:index", point)).aggregate_array(dates.get(i));
  return values;


When I run the code, I get the following error: the spaced points: Layer error: Image.projection: The bands of the specified image contains different projections. Use Image.select to pick a single band. Can anyone tell me what's wrong?


As the error tells you, the image you use to get the projection from (variable 'multiband') contains 351 bands of which not all have the same projection.

You can fix it by taking the projection of just one band, either by selecting with a number or by a specified name. Make sure you check whether you selected the appropriate projection:

// use function to get the spaced points, projection of the first band:
var points = spacedPoints(AOI, multiband.select(0).projection());

// use function to get the spaced points, projection of a specified band:
var points = spacedPoints(AOI, multiband.select("04_15_2018-04-15").projection());

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.