I need help in Google Earth engine #13
Unanswered
luannpedro
asked this question in
Q&A
Replies: 1 comment
-
// Load the SRTM dataset
var srtm = ee.Image('CGIAR/SRTM90_V4');
// Define the area of interest (AOI)
var aoi = ee.Geometry.Rectangle([xmin, ymin, xmax, ymax]);
// Generate 96 random points within the AOI
var randomPoints = ee.FeatureCollection.randomPoints(aoi, 96);
// Buffer each point to create 500m areas
var areas = randomPoints.map(function(point) {
return point.buffer(500);
});
// Load SoilGrids and WorldClim datasets
var soilGrids = ee.ImageCollection('SoilGrids/soilgrids250m');
var worldClim = ee.ImageCollection('WORLDCLIM/V1');
// Function to sample points within each area
var samplePoints = function(area) {
var points = ee.FeatureCollection.randomPoints(area.geometry(), 30);
var sampled = points.map(function(point) {
var values = srtm.sample(point).first()
.combine(soilGrids.sample(point).first())
.combine(worldClim.sample(point).first());
return point.set(values);
});
return sampled;
};
// Apply the sampling function to each area
var sampledAreas = areas.map(samplePoints).flatten();
// Print the result
print(sampledAreas);
// Export the result to a CSV file
Export.table.toDrive({
collection: sampledAreas,
description: 'SampledAreas',
fileFormat: 'CSV'
}); Explanation:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear members of the community, I need to cut 96 areas with altimetry from 500 meters within an SRTM, later, I need to overlay these areas with other rasters of environmental variables from the soilgrid and worldclim. Within the cropped areas you need to select 30 random points within each area and extract the pixel values per layer of variables and per area. I would like to perform this task in Earth Engine. Would there be a script to perform this task?
Beta Was this translation helpful? Give feedback.
All reactions