-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode for Accessing GEE Console.txt
35 lines (25 loc) · 1.3 KB
/
Code for Accessing GEE Console.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
READ THIS
This helped me get additional (longitude,latitudes) 500 points (250 croplands, 350 non croplands).
This aimed to bolster performance of model on the data.
You need to create account and a project under google earth to check it out.
Once you have done so, proceed to use this code on the console and run.
CODE:
// Define a region of interest (ROI) for Afghanistan
var roi = ee.Geometry.Rectangle([60.86, 29.38, 74.93, 38.49]); // Replace with the coordinates for Afghanistan
// Define the desired date range
var startDate = '2022-04-01';
var endDate = '2022-04-30';
// Filter Sentinel-2 imagery by date and location
var collection = ee.ImageCollection('COPERNICUS/S2')
.filterBounds(roi)
.filterDate(startDate, endDate);
// Get the most recent image from the collection
var image = ee.Image(collection.sort('system:time_start', false).first());
print(image);
// Display the image on the map
Map.centerObject(roi, 6);
Map.addLayer(image, {bands: ['B4', 'B3', 'B2'], max: 3000}, 'Sentinel-2 Image'); // Use Sentinel-2 bands (B4, B3, B2)
Map.setCenter(68.89, 34.94, 12); // Adjust the coordinates and zoom level as needed
// Print the image acquisition date
var acquisitionDate = ee.Date(image.get('system:time_start'));
print('Image Acquisition Date:', acquisitionDate);