Para extraer correctamente la información de trama de un featureCollection
debe utilizar sampleRegions
. El primer paso es transformar la colección de series temporales en un raster multibanda, donde cada banda corresponde a cada imagen de la serie temporal. Después, hay que utilizar sampleRegions
para extraer los valores raster y utilizando el argumento geometry: true
para que se devuelva una geometría para cada característica. Por último, hay que transformar la geometría en una tabla simple obteniendo las coordenadas de la geometría y, después, eliminarlas.
// Transform image collection of VH band into image with n bands
var timeSeries = ee.ImageCollection(image_collection.select('VH')).toBands()
// Set masked values as -11000, set sameFootprint as false to override original image footprint (useful for working in areas with several tiles)
.unmask({value: 0, sameFootprint: false});
// Extract data for each point
var sampledReg = ee.Image(timeSeries)
.sampleRegions({
// Get the sample from the points FeatureCollection.
collection: points,
// Properties from the points collection to pass on to the sampled info
//properties: ['id'],
// Set the scale to get Sentinel pixels in the FeatureCollection.
scale: 30,
tileScale: 8,
// Return geometries
geometries: true
});
// Transform coordinates into properties in the table.
var featColExport = sampledReg.map(function (feature) {
// Get geometry
var coordinates = feature.geometry()
// Transform it to the desired EPSG code. Here WGS 84
.transform('epsg:4326')
// Get coordinates as a list
.coordinates();
// Get both entries of coordinates and set them as new properties
var resul = feature.set('lon', coordinates.get(0),
'lat', coordinates.get(1));
// Remove geometry
return resul.setGeometry(null);
});
// Export table as csv
Export.table.toDrive({
collection: featColExport,
description: 'pointsExtractCoords',
fileFormat: 'CSV',
});