The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
library(irg)
Just swap the regions with your own features or points and run!
To access an example script for extracting NDVI from MODIS MOD13Q1 imagery in Earth Engine, run:
use_example_ee_script(sensor = 'MODIS')
// Sample NDVI for IRG - MODIS MOD13Q1
// Example from irg package https://github.com/robitalec/irg
// Alec L. Robitaille
// Functions ===================================================================
function rescaleBands (im) {
= im.select(['NDVI', 'EVI']).multiply(0.0001);
var viBands = im.select('sur_refl_b0.*').multiply(0.0001);
var surfBands = im.select(['ViewZenith', 'SolarZenith', 'RelativeAzimuth']).multiply(0.01);
var viewBands
return(im.addBands(viBands, null, true)
.addBands(surfBands, null, true)
.addBands(viewBands, null, true));
}
// Function to grab year from image and add it as a band
function addYear(img) {
return(img.addBands(ee.Image(img.date().get('year')).rename('yr')));
}
// Function to sample an image in each region of supplied geometry
function sampleRegions (im) {
return(im.reduceRegions(features, ee.Reducer.mean(), 250)
.copyProperties(im));
}
// Feature ====================================================================
= ee.FeatureCollection(
var features ee.Feature(ee.Geometry.Point([-109.96, 53.853]),
["id": "0"}),
{ee.Feature(ee.Geometry.Point([-109.94, 53.852]),
"id": "1"}),
{ee.Feature(ee.Geometry.Point([-109.95, 53.851]),
"id": "2"}),
{ee.Feature(ee.Geometry.Point([-109.93, 53.854]),
"id": "3"}),
{ee.Feature(ee.Geometry.Point([-109.92, 53.853]),
"id": "4"}),
{ee.Feature(ee.Geometry.Point([-109.94, 53.852]),
"id": "5"}),
{ee.Feature(ee.Geometry.Point([-109.93, 53.851]),
"id": "6"})]);
{
// Images ======================================================================
= ee.ImageCollection('MODIS/006/MOD13Q1');
var modis
// Filter ======================================================================
= modis.filterDate('2015-01-01', '2020-01-01')
modis .filterBounds(features);
// Process images ==============================================================
// Add dates
= modis.map(addYear)
modis .map(rescaleBands);
// Sample images ===============================================================
= modis.map(sampleRegions)
var sample .flatten()
.filter(ee.Filter.neq('NDVI', null));
// Export ======================================================================
Export.table.toDrive({
: sample,
collection: 'sampled-ndvi-MODIS-MOD13Q1',
description: ['id', 'NDVI', 'SummaryQA', 'DayOfYear', 'yr']
selectors });
To access an example script for extracting NDVI from Landsat 8 imagery in Earth Engine, run:
use_example_ee_script(sensor = 'Landsat')
// Sample NDVI for IRG - Landsat
// Example from irg package https://github.com/robitalec/irg
// Alec L. Robitaille
// Functions ===================================================================
// Function to add mask identifying cloud and saturation
// Mask band = if QA_PIXEL indicates unwanted pixels +
// if QA_RADSAT indicates saturated pixels
// Either = 0 (good), 1 (one of two masking conditions), 2 (both conditions)
// Adapted from: Examples/Cloud Masking/Landsat8 Surface Reflectance
function addMask(image) {
// Bit 0 - Fill
// Bit 1 - Dilated Cloud
// Bit 2 - Cirrus
// Bit 3 - Cloud
// Bit 4 - Cloud Shadow
= image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).neq(0);
var qaMask = image.select('QA_RADSAT').neq(0);
var saturationMask = qaMask.add(saturationMask);
var mask
// Apply the scaling factors to the appropriate bands.
= image.select('SR_B.').multiply(0.0000275).add(-0.2);
var opticalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);
var thermalBands
// Replace the original bands with the scaled ones and apply the masks.
image.addBands(opticalBands, null, true)
return .addBands(thermalBands, null, true)
.addBands(mask.rename('mask'));
}
// Function to calculate NDVI and add it as a band
function calcNDVI(im) {
= im.normalizedDifference(['SR_B5','SR_B4']).rename('ndvi');
var ndvi im.addBands(ndvi);
return
}
// Function to grab date from image and add it as a band
function addDates(im) {
= im.date();
var date im.addBands(ee.Image([date.getRelative('day', 'year'),
return date.get('year')])
.rename(['doy', 'year'])).float();
}
// Function to sample an image in each region of supplied geometry
function sampleRegions (im) {
return(im.reduceRegions(features, ee.Reducer.mean(), 30)
.copyProperties(im));
}
// Feature ====================================================================
= ee.FeatureCollection(
var features ee.Feature(ee.Geometry.Point([-109.96, 53.853]),
["id": "0"}),
{ee.Feature(ee.Geometry.Point([-109.94, 53.852]),
"id": "1"}),
{ee.Feature(ee.Geometry.Point([-109.95, 53.851]),
"id": "2"}),
{ee.Feature(ee.Geometry.Point([-109.93, 53.854]),
"id": "3"}),
{ee.Feature(ee.Geometry.Point([-109.92, 53.853]),
"id": "4"}),
{ee.Feature(ee.Geometry.Point([-109.94, 53.852]),
"id": "5"}),
{ee.Feature(ee.Geometry.Point([-109.93, 53.851]),
"id": "6"})]);
{
// Images ======================================================================
= ee.ImageCollection('LANDSAT/LC08/C02/T1_L2');
var l8
// Filter ======================================================================
= l8.filterDate('2015-01-01', '2020-01-01')
l8 .filterBounds(features);
// Process images ==============================================================
// Mask clouds and calculate NDVI
= l8.map(addMask)
l8 .map(addDates)
.map(calcNDVI);
// Sample images ===============================================================
= l8.map(sampleRegions)
var sample .flatten();
// Export ======================================================================
Export.table.toDrive({
: sample,
collection: 'sampled-ndvi-Landsat-LC08-T1-L2',
description: ['id', 'ndvi', 'mask', 'doy', 'year']
selectors });
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.