Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spatialthoughts committed Jul 31, 2024
1 parent d970605 commit 2b6096f
Show file tree
Hide file tree
Showing 20 changed files with 1,868 additions and 1,572 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');
// Find the name of the urban centre
// by adding the layer to the map and using Inspector.
var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));

var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

var rgbVis = {
Expand Down
4 changes: 3 additions & 1 deletion code/end_to_end_gee/01-Earth-Engine-Basics/08a_Export
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));
var geometry = filtered.geometry();

var rgbVis = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

var rgbVis = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,25 @@ function maskL8sr(image) {
.copyProperties(image, ['system:time_start']);
}

// Apply cloud-mask and rename bands
// Apply filters, cloud-mask and rename bands
// Filters from https://github.com/google/earthengine-catalog/blob/main/pipelines/landsat.py
var L5 = L5
.filter(ee.Filter.lt('WRS_ROW', 122)) // Remove night-time images.
.map(maskL457sr)
.select(l5Bands,l5names)
.select(l5Bands,l5names);

var L7 = L7
.filter(ee.Filter.lt('WRS_ROW', 122)) // Remove night-time images.
.filter(ee.Filter.date('1984-01-01', '2017-01-01')) // Orbital drift after 2017.
.map(maskL457sr)
.select(l7Bands,l7names)
.select(l7Bands,l7names);

var L8 = L8
.filterDate(ee.Filter.date('2013-05-01', '2099-01-01')) // Images before May 1 had some pointing issues.
.filter(ee.Filter.neq('NADIR_OFFNADIR', 'OFFNADIR'))
.filter(ee.Filter.lt('WRS_ROW', 122)) // Remove night-time images.
.map(maskL8sr)
.select(l8Bands,l8names)
.select(l8Bands,l8names);

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Step 3a: Verify Radiometric Calibration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Example script showing how to visualize
// all the bands of an image
// 1. Filmstrip: Create a tiled image with all the bands
// 2. Animation: Create a video with a frame for each band

var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var geometry = ee.Geometry.Polygon([[
[77.57018, 12.96010],
[77.57018, 12.93953],
[77.59988, 12.93953],
[77.59988, 12.96010]]
]);

var filteredS2 = s2.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30))
.filter(ee.Filter.date('2019-01-01', '2020-01-01'))
.filter(ee.Filter.bounds(geometry));

// Sort the collection and pick the least cloudy image
var filteredS2Sorted = filteredS2.sort('CLOUDY_PIXEL_PERCENTAGE');
var image = filteredS2Sorted.first();

// Convert the multi-band image to an ImageCollection
var bands = image.select('B.*').bandNames();

// Remove the 'Cirrus' band
var bandsToUse = bands.remove('B10');

// Tip: change the bandsToUse variable to a smaller list
// such as ['B1', 'B2', 'B3', 'B4] to create shorter
// filmstrips and repeat for other bands

// map() a function on the list of bands
var bandCol = ee.ImageCollection(bandsToUse.map(function(band) {
// All images in a collection are expected to have the same bands
// Set the name of hte bands to 'band'
var bandImage = image.select([band]).rename('band');
// Set the image ID to the actual name of the band. i.e. B1, B2 etc.
return bandImage.set('system:index', band);
}));

// Define arguments for the getFilmstripThumbURL function parameters.
var filmArgs = {
dimensions: 800,
region: geometry,
crs: 'EPSG:3857',
min: 500,
max: 2700,
palette: ['black', 'white']
};

// Print a URL that will produce the filmstrip when accessed.
print('Film Strip (click to view)', bandCol.getFilmstripThumbURL(filmArgs));

// Create an Animation
var videoArgs = {
dimensions: 800,
region: geometry,
crs: 'EPSG:3857',
framesPerSeconds: 1,
min: 500,
max: 2700,
palette: ['black', 'white']
};

print('Animation (click to view)', bandCol.getVideoThumbURL(videoArgs));

var rgbVis = {min: 0.0, max: 3000, bands: ['B4', 'B3', 'B2']};

Map.centerObject(geometry, 10);
Map.addLayer(image, rgbVis, 'Image');

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');
// Find the name of the urban centre
// by adding the layer to the map and using Inspector.
var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));

var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

var rgbVis = {
Expand Down
4 changes: 3 additions & 1 deletion docs/code/end_to_end_gee/01-Earth-Engine-Basics/08a_Export
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));
var geometry = filtered.geometry();

var rgbVis = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var urban = ee.FeatureCollection('users/ujavalgandhi/e2e/ghs_urban_centers');

var filtered = urban.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'));
var filtered = urban
.filter(ee.Filter.eq('UC_NM_MN', 'Bengaluru'))
.filter(ee.Filter.eq('CTR_MN_NM', 'India'));

var geometry = filtered.geometry();

var rgbVis = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,25 @@ function maskL8sr(image) {
.copyProperties(image, ['system:time_start']);
}

// Apply cloud-mask and rename bands
// Apply filters, cloud-mask and rename bands
// Filters from https://github.com/google/earthengine-catalog/blob/main/pipelines/landsat.py
var L5 = L5
.filter(ee.Filter.lt('WRS_ROW', 122)) // Remove night-time images.
.map(maskL457sr)
.select(l5Bands,l5names)
.select(l5Bands,l5names);

var L7 = L7
.filter(ee.Filter.lt('WRS_ROW', 122)) // Remove night-time images.
.filter(ee.Filter.date('1984-01-01', '2017-01-01')) // Orbital drift after 2017.
.map(maskL457sr)
.select(l7Bands,l7names)
.select(l7Bands,l7names);

var L8 = L8
.filterDate(ee.Filter.date('2013-05-01', '2099-01-01')) // Images before May 1 had some pointing issues.
.filter(ee.Filter.neq('NADIR_OFFNADIR', 'OFFNADIR'))
.filter(ee.Filter.lt('WRS_ROW', 122)) // Remove night-time images.
.map(maskL8sr)
.select(l8Bands,l8names)
.select(l8Bands,l8names);

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Step 3a: Verify Radiometric Calibration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Example script showing how to visualize
// all the bands of an image
// 1. Filmstrip: Create a tiled image with all the bands
// 2. Animation: Create a video with a frame for each band

var s2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED');
var geometry = ee.Geometry.Polygon([[
[77.57018, 12.96010],
[77.57018, 12.93953],
[77.59988, 12.93953],
[77.59988, 12.96010]]
]);

var filteredS2 = s2.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30))
.filter(ee.Filter.date('2019-01-01', '2020-01-01'))
.filter(ee.Filter.bounds(geometry));

// Sort the collection and pick the least cloudy image
var filteredS2Sorted = filteredS2.sort('CLOUDY_PIXEL_PERCENTAGE');
var image = filteredS2Sorted.first();

// Convert the multi-band image to an ImageCollection
var bands = image.select('B.*').bandNames();

// Remove the 'Cirrus' band
var bandsToUse = bands.remove('B10');

// Tip: change the bandsToUse variable to a smaller list
// such as ['B1', 'B2', 'B3', 'B4] to create shorter
// filmstrips and repeat for other bands

// map() a function on the list of bands
var bandCol = ee.ImageCollection(bandsToUse.map(function(band) {
// All images in a collection are expected to have the same bands
// Set the name of hte bands to 'band'
var bandImage = image.select([band]).rename('band');
// Set the image ID to the actual name of the band. i.e. B1, B2 etc.
return bandImage.set('system:index', band);
}));

// Define arguments for the getFilmstripThumbURL function parameters.
var filmArgs = {
dimensions: 800,
region: geometry,
crs: 'EPSG:3857',
min: 500,
max: 2700,
palette: ['black', 'white']
};

// Print a URL that will produce the filmstrip when accessed.
print('Film Strip (click to view)', bandCol.getFilmstripThumbURL(filmArgs));

// Create an Animation
var videoArgs = {
dimensions: 800,
region: geometry,
crs: 'EPSG:3857',
framesPerSeconds: 1,
min: 500,
max: 2700,
palette: ['black', 'white']
};

print('Animation (click to view)', bandCol.getVideoThumbURL(videoArgs));

var rgbVis = {min: 0.0, max: 3000, bands: ['B4', 'B3', 'B2']};

Map.centerObject(geometry, 10);
Map.addLayer(image, rgbVis, 'Image');

Loading

0 comments on commit 2b6096f

Please sign in to comment.