0

I have a feature collection with point locations of historic wildfires. I would like to map over this feature collection and for each feature, sample windspeed ('vs' band) from GRIDMET for the corresponding location and day (mean of that day and the following day). I have written code which does do this, however it takes about 3 hours for the output task to complete in GEE.

I suspect this is because there is a large amount of points (>80,000) and in my existing code, for every point, the mean for across its two days is being calculated for the entire US before the value at that point is sampled! This is obviously not efficient, and since I plan to use this code to extract other weather variables that would require averaging over longe time periods (i.e., the prior 6 months) I fear that the processing time will become unmanageable.

Some approaches I've tried:

  • Using clip within the map function, but per GEE Coding Best Practices this actually slows things down.
  • Clipping the GRIDMET image collection to just my study area (California) prior to mapping, but this increased processing time.
  • Using .filterBounds(point) prior to the mean calculation but when testing this outside the map function on a single feature, I see that it doesn't actually filter the GRIDMET collection at all. Either I'm implementing it incorrectly or it can't filter GRIDMET because its a single image for the entire US.
  • Increasing the scale - I tried increasing scale from 30 to 4000 (as GRIDMET resolution is 2.5 arc min, roughly 4km). I am testing this now but when testing for a single feature it did not improve performance.

Ideally, I would like to update my map function to filter the image collection to just around a particular point before it calculates the mean across multiple days. If this is not possible, is there any way I could optimize my code to avoid calculating means across such a large area?

Here is my full code. I have made the feature collection publicly viewable for testing.

# wildfire points/dates
WF_pts = ee.FeatureCollection('users/allanbkapoor/wildfires2')

# GRIDMET
GRIDMET = ee.ImageCollection('IDAHO_EPSCOR/GRIDMET')

# windspeed band
windspeed = GRIDMET.select('vs')

# define function that gets pixels value for a single feature based on long/lat and date
def get_single_date_value(feat):
    
    #get data for that feature from date column
    date = ee.Date(feat.get('DISCOVERY_DT'))
    date2 = date.advance(1, 'day')
    
    projection_obj = ee.Projection('EPSG:4326')
    point = feat.get('LONGITUDE_LATITUDE')
    scale = 30
    
    #for single date: filter image collection to just the image for the feature's date
    windImage = windspeed.filterBounds(point).filterDate(date,date2).mean()
    
    point_value_fc = windImage.sample(point, scale, projection=projection_obj)
    point_value = point_value_fc.first().get("vs")
    
    return feat.set({'wind_speed': point_value})

#map the function over the feature collection
WF_pts_wind = WF_pts.map(get_single_date_value)

1 Answer 1

0

A few thoughts (which are too long for a comment):

Using .reduceRegion without giving a projection and using a scale closer to the native scale of GRIDMET might speed things up. I only tested the speed on 1000 elements which took about 20 seconds, can't say how that scales though.

function get_single_date_value(feat){
    var date = ee.Date(feat.get('DISCOVERY_DT'))
    var date2 = date.advance(1, 'day')
    
    var projection_obj = ee.Projection('EPSG:4326')
    var point = feat.get('LONGITUDE_LATITUDE')
    var scale = 3000
    var windImage = windspeed.filterBounds(point).filterDate(date,date2).mean()
    
    var point_value_fc = windImage.reduceRegion(ee.Reducer.first(), point, 3000)
    
    return feat.set(point_value_fc)
}

(I'm working in the Javascript interface, but you should be able to quickly adapt the code to test it)

One thing which might speed up things a bit more would be to get a list of list of all unique DISCOVERY_DT and map over that, using reduceRegions() to get the values for multiple points. However saving the properties in that case is a bit more complicated and it's only really worth it if there's many points with the same dates.

EDIT: Also I wouldn't worry too much about Earth Engine calculating more than it needs. If you use some spatial reducer it should only calculate values for the geometry that is given.

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.