I'm new to Earth Engine and am having a difficult time determining what the best method of obtaining tabular data at the pixel level based on raster and vector data inputs and geographic points of interest.
I have a fusion table of geographic points of interest for Africa ("interest"), the Hansen Global Forest Cover Watch rasters ("gfc2014_c"), and a Shapefile of districts and countries in sub-Saharan Africa ("SSA").
//Load the Hansen data and create layers
var gfc2014 = ee.Image('UMD/hansen/global_forest_change_2015');
//Load the SSA administrative district shapefile
var SSA = ee.FeatureCollection('users/salem043/Africa_Districts')
//Crop the Hansen data we are interested in to the SSA admin shapefile
var gfc2014_c = gfc2014.clip(SSA);
//Load the data points of interest from the fusion table
var interest = ee.FeatureCollection('ft:1DCL5m_EO8kKMis2BWTdzfg-i9uc4uAZ2xNLQuhf7');
I want to extract the GFC data (all underlying bands) for each of the points of interest. But I also want the information from the shapefile - I need variables that identify which geometries the points lie in.
The one page I found with some information on this task was here:
So I tried their method, just using the GFC data, which looks like the following (again, this is mostly taken from the link above).
var mapfunc = function(feat) {
// get feature id
var id = ee.String(feat.id())
// get feature geometry
var geom = feat.geometry()
// make an empty list to store the features
var newfc = ee.List([])
// function to iterate over the ImageCollection
var addProp = function(img, fc) {
// the initial value is the empty list
fc = ee.List(fc)
// get the date as string
var date = img.date().format()
// extract the value of 'waterClass'
var value = img.reduceRegion(ee.Reducer.first(), geom, 30).get('waterClass')
// If the value is null then store it as 'No data'
var val = ee.String(ee.Algorithms.If(value, ee.String(value), ee.String('No data')))
// make the name of the feature (feat_id-date)
var featname = ee.String("feat_").cat(id).cat(ee.String("-")).cat(date)
// make the Feature
var newfeat = ee.Feature(geom, {name:featname,
value:val})
// add the value to the list
return fc.add(newfeat)
}
var newfeat = ee.FeatureCollection(ee.List(gfc2014.iterate(addProp, newfc)))
return newfeat
};
var newft = interest.map(mapfunc).flatten();
Export.table.toDrive(newft,
"export_Points",
"export_Points",
"export_Points");
When I run this I get an error that "gfc2014.iterate is not a function"
Even if I could get the function above working, I don't know how to also extract other information from the shapefile. The end result should have point of interest ID (which is in the fusion table), point of interest country, district, and all Hansen data values for the point of interest.
I am so grateful for any leads or suggestions! Thank you so much for your time!