Created
May 22, 2020 17:29
-
-
Save twnawrocki/39fea181f3abf28ce2958e1067ea4987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define an area of interest property for Point Lay. | |
var aoi = ee.Geometry.Rectangle(-162.7,69.4, -163.4,69.9); | |
// Import the Sentinel-1 Image Collection VV and VH polarizations within study area and date range | |
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD') | |
.filterBounds(aoi) | |
.filter(ee.Filter.date('2018-08-19', '2018-10-19')) | |
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV')) | |
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH')) | |
.filter(ee.Filter.eq('instrumentMode', 'IW')) | |
.sort('system:time_start'); | |
print("Sentinel 1 (date-filtered:", sentinel1); | |
// Filter to get images from different look angles. | |
var ascending = sentinel1.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING')); | |
var descending = sentinel1.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING')); | |
// Create a composite from means at different polarizations and look angles. | |
var composite = ee.Image.cat([ | |
ascending.select('VH').mean(), | |
ee.ImageCollection(ascending.select('VV').merge(descending.select('VV'))).mean(), | |
descending.select('VH').mean() | |
]).focal_median(); | |
// Add image to the map. | |
Map.centerObject(aoi); | |
Map.addLayer(composite, {min: [-25, -20], max: [0, 10]}, 'composite'); | |
/* | |
FUNCTION: Download All Images | |
Description: This function exports each image in an image collection. | |
Author: Rodrigo E. Principe | |
Source: https://github.com/fitoprincipe | |
Version Date: 2018-12-03 | |
*/ | |
var tools = require('users/fitoprincipe/geetools:tools') | |
var Task = function(taskId, config) { | |
this.id = taskId | |
this.config = config | |
} | |
Task.prototype.start = function() { | |
ee.data.startProcessing(this.id, this.config) | |
} | |
var IMAGE_TYPES = function(img, type) { | |
var types = {"float":img.toFloat(), | |
"byte":img.toByte(), | |
"int":img.toInt(), | |
"double":img.toDouble(), | |
"long": img.toLong(), | |
"short": img.toShort(), | |
"int8": img.toInt8(), | |
"int16": img.toInt16(), | |
"int32": img.toInt32(), | |
"int64": img.toInt64(), | |
"uint8": img.toUint8(), | |
"uint16": img.toUint16(), | |
"uint32": img.toUint32()} | |
return types[type] | |
} | |
var Download = {'ImageCollection': {}, 'Table': {}} | |
Download.ImageCollection.toDrive = function(collection, folder, options) { | |
var defaults = { | |
scale: 10, | |
maxPixels: 1e30, | |
type: 'float', | |
region: aoi, | |
name: null} | |
var opt = tools.get_options(defaults, options) | |
var n = collection.size().getInfo(); | |
var colList = collection.toList(n); | |
var colID = opt.name || collection.getInfo()['id'] || "" | |
colID = colID.replace('/','_') | |
for (var i = 0; i < n; i++) { | |
var img = ee.Image(colList.get(i)); | |
var id = img.id().getInfo() || colID+'_image_'+i.toString(); | |
var region = opt.region || img.geometry().bounds().getInfo()["coordinates"]; | |
var imtype = IMAGE_TYPES(img, opt.type) | |
Export.image.toDrive({ | |
image: imtype, | |
description: id, | |
folder: folder, | |
fileNamePrefix: id, | |
region: region, | |
scale: opt.scale, | |
crs: opt.projection, | |
maxPixels: opt.maxPixels | |
}) | |
} | |
} | |
/* | |
END FUNCTION | |
*/ | |
// Set download options for land surface temperature | |
var options = { | |
scale: 10, | |
maxPixels: 1e30, | |
type: 'float', | |
region: aoi, | |
name: null, | |
} | |
// Define output folder | |
var outFolder = 'sentinel1' | |
// Download all images in the Sentinel-1 collection | |
Download.ImageCollection.toDrive(sentinel1, outFolder, options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment