1

Is there an efficient way to obtain the outline of a country (e.g., Australia) based on feature collection instead of drawing with the geometry tool?

Input:

var AUS_comp = ee.FeatureCollection("USDOS/LSIB/2013").filterMetadata("cc","equals","AS")

Output:

enter image description here

P/S: My initial objectives was to plot a graph via ui.Chart.image.doySeriesByYear of a dataset (FIRMS hotspots) across the country. However, filtering with the AUS_comp feature collections seems to be consuming too much resources and resulting in user memory exceeded / computation timeout. I am not sure whether converting the feature collections to a single polygon would be the best solution for this issue.

Full code (JavaScript) Google Earth Engine:

var AUS = ee.Geometry.Polygon(
        [[[127.3689462855952, -13.491075137327103],[123.8533212855952, -16.29372317317216],[121.5681650355952, -17.638732215007032], [120.4255869105952, -19.637359606938393],
          [116.1189462855952, -20.627589346224404],[113.3943369105952, -23.316982594400656],[113.6580087855952, -25.55725738666083],[114.8884775355952, -30.216305297255722],
          [114.6248056605952, -33.64658749466065],[116.7341806605952, -34.95344585475264],[120.0740244105952, -34.66479312507612],[122.8865244105952, -34.30255856657303],
          [126.2263681605952, -32.69019447983865],[130.4451181605952, -31.798174980040457],[133.5212900355952, -32.542133943536214],[135.2791025355952, -35.169270873633344],
          [137.6521494105952, -34.22992311043601],[139.4978525355952, -37.43556659275122],[145.5623056605952, -39.02340657205664],[149.5173837855952, -38.061021987992696],
          [152.1541025355952, -34.66479312507612],[153.2087900355952, -25.319148988654078],[146.6169931605952, -18.640985563798928],[142.2224619105952, -11.086718680136846],
          [141.3435556605952, -15.617690983472107],[140.1130869105952, -17.387282126561526],[136.0701181605952, -14.769515119489446],[137.0369150355952, -12.033891737255088],
          [132.2908212855952, -11.259168237228634],[129.2146494105952, -14.088573349609213]]]);
var AUS_comp = ee.FeatureCollection("USDOS/LSIB/2013").filterMetadata("cc","equals","AS")

Map.addLayer(AUS_comp,{},'self drawn australlia')
Map.addLayer(AUS,{color: 'red'},'aus from feature collection')
Map.centerObject(AUS_comp,5);

// Filter based on single drawn polygon (AUS) - no issue
var dataset = ee.ImageCollection('FIRMS').select('T21').filterDate('2019-01-01', '2020-03-31');
var series = ui.Chart.image.doySeriesByYear(dataset, 'T21', AUS, ee.Reducer.count())
                                                    .setOptions({
                                                      title: 'Number of fires in Australia',
                                                       vAxis: {title: 'Number of Fires'},
                                                       hAxis: {title: 'Day of Year'}});
print(series); 


//Filter bound based on the feature collection - too many multipolgon - user memory exceeded / computation timeout
var dataset = ee.ImageCollection('FIRMS').select('T21').filterDate('2019-01-01', '2020-03-31');
var series1 = ui.Chart.image.doySeriesByYear(dataset, 'T21', AUS_comp, ee.Reducer.count())
                                                    .setOptions({
                                                      title: 'Number of fires in Australia',
                                                       vAxis: {title: 'Number of Fires'},
                                                       hAxis: {title: 'Day of Year'}});
print(series1); 

1 Answer 1

2

Somehow the chart.image() functionality prefer to have inputs of type geometry() as opposed to ee.Feature(). This might solve your issue partially:

var series1 = ui.Chart.image.doySeriesByYear({imageCollection: dataset, 
                                              bandName:'T21', region:largest.geometry(), 
                                              regionReducer:ee.Reducer.count(),
                                              scale:1000})
                                                    .setOptions({
                                                      title: 'Number of fires in Australia',
                                                       vAxis: {title: 'Number of Fires'},
                                                       hAxis: {title: 'Day of Year'}});

It is still good practice though to reduce the amount of vertices when you don't need them, e.g. by creating a bbox, convex hull or something similar. You can do that for the entire FeatureCollection or create a convex hull and do it for each feature seperately. You can then also add a area estimate to filter on, e.g. select the largest or only land masses above a certain threshold:

var Aus_simple = AUS_comp.map(function(x){
  var simpleFeat = x.simplify(1000)
  
  var area = simpleFeat.area() // in m2
  var convex = x.convexHull(1000)
  var areaConvex = convex.area() // in m2

  return(convex.copyProperties(x).set({area:area,
    areaConvex: areaConvex
  }))
})

https://code.earthengine.google.com/f8b4d27e6bab684805121492bab72d49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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