Reputation: 299
I am trying to extract sentinel-1 time series data for different locations from earth engine. The locations in this case are not present in single sentinel-1 image, but are distributed in several images. Following is the code I have tried. However, I am not able to do it properly. Please guide me in this regard.
// Define the locations you want to retrieve data for
var locations = [
ee.Geometry.Point([-120.1331, 39.3272]), // Location 1
ee.Geometry.Point([-121.9730, 37.3280]), // Location 2
ee.Geometry.Point([-118.4085, 33.9416]), // Location 3
];
// Create an ee.FeatureCollection object from the locations array
var locationsFC = ee.FeatureCollection(locations.map(function(location) {
return ee.Feature(location);
}));
var pointStyle = {
color: 'FF0000', // red
fillColor: 'FF0000',
pointSize: 8
};
// Add the ee.FeatureCollection object to the map
Map.addLayer(locationsFC.style(pointStyle), {}, 'My Shapefile');
// Define the time range you want to retrieve data for
var startDate = '2023-01-01';
var endDate = '2023-01-20';
// Load Sentinel-1 SAR data
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(ee.Geometry.MultiPoint(locations))
.filterDate(startDate, endDate)
.select(['VV']);
print(sentinel1);
// Define the target projection as WGS84
var wgs84 = ee.Projection('EPSG:4326');
// Define a function to reproject an image to WGS84
function reprojectToWGS84(image) {
var reprojected = image.reproject({
crs: wgs84,
scale: 10 // set the scale to use for the reprojection
});
return reprojected;
}
// Apply the function to the sentinel1 image collection
var sentinel1_wgs84 = sentinel1.map(reprojectToWGS84);
print(sentinel1_wgs84);
// Define the scale at which to sample the image
var scale = 10;
// Define a function to sample the image at the points
function sampleImage(image) {
return image.select(['VV']).sampleRegions({
collection: locationsFC,
scale: scale,
tileScale: 16
});
}
// Define the export file name
var fileName = 'sentinel1_vv_data';
// Select the VV band from the image collection
var vv = sentinel1_wgs84.select('VV');
// Sample the VV data at the point locations
var sampledData = vv.sampleRegions({
collection: locationsFC,
scale: scale
});
// Export the sampled data as a CSV file
Export.table.toDrive({
collection: sampledData,
description: fileName,
fileFormat: 'CSV'
});
Upvotes: 1
Views: 192