-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16b14f1
commit f768595
Showing
18 changed files
with
3,319 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
import oauth2client | ||
import ee | ||
|
||
ee.Initialize() | ||
|
||
## Polygon area for extraction | ||
## Polygon area for extraction | ||
geom=ee.Geometry.Polygon( | ||
[[[-72.050, -9.128], | ||
[-72.050, -9.235], | ||
[-71.916, -9.235], | ||
[-71.916, -9.128]]]) | ||
|
||
## Landsat 5 Collection | ||
l5=ee.ImageCollection('LANDSAT/LT05/C01/T1_SR').filterDate('1998-01-01', '2011-11-30').filterBounds(geom) | ||
|
||
def exportCollectionToDrive (userCollection,folderName): | ||
userCollection2=userCollection#.map(toals) | ||
imageList = ee.List(userCollection2.toList(userCollection2.size().add(1))) | ||
length = userCollection2.size().getInfo() | ||
print(length) | ||
|
||
|
||
def exportImage(img): | ||
fileName = ee.String(img.get('system:index')).getInfo() | ||
fileGeometry = geom.bounds().getInfo()['coordinates'][0] | ||
band=ee.Image(img).bandNames().get(0) | ||
sc=30 ##pixel size | ||
|
||
## Masking | ||
cloud=img.select('pixel_qa').bitwiseAnd(32).neq(0) | ||
img=img.updateMask(cloud.Not()) | ||
cloud_shadow = img.select('pixel_qa').bitwiseAnd(8).neq(0) | ||
img=img.updateMask(cloud_shadow.Not()) | ||
|
||
##Check overlap | ||
area=ee.Feature(geom).geometry().area() | ||
imgarea=ee.Image(img).multiply(0).add(1).clip(geom).reduceRegion( | ||
reducer= ee.Reducer.sum().unweighted(), | ||
geometry= geom, | ||
maxPixels= 1e12, | ||
tileScale= 1, | ||
scale=30) | ||
imgp=ee.Number(imgarea.get(band)).multiply(sc).multiply(sc).divide(area) | ||
|
||
##Check for overlap | ||
if imgp.getInfo()>=0.8: | ||
task = ee.batch.Export.image.toDrive( | ||
image = img.normalizedDifference(['B4', 'B3']).rename('NDVI').toFloat(), | ||
description = fileName, | ||
folder = 'gee-collection-acre-landsat5', | ||
maxPixels = 1e13, | ||
region = fileGeometry, | ||
scale = 30) | ||
task.start() | ||
|
||
|
||
index = 0 | ||
while index < length: | ||
print("Export #: " + str(index+1)) | ||
img2export = ee.Image(imageList.get(index)) | ||
exportImage(img2export) | ||
index = index + 1 | ||
time.sleep(1) # sleep for 1 seconds | ||
|
||
print('Finished exporting data') | ||
print('') | ||
exportCollectionToDrive(userCollection=l5, folderName="gee-collection-acre-landsat5") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
import oauth2client | ||
import ee | ||
|
||
ee.Initialize() | ||
|
||
## Polygon area for extraction | ||
geom=ee.Geometry.Polygon( | ||
[[[-72.050, -9.128], | ||
[-72.050, -9.235], | ||
[-71.916, -9.235], | ||
[-71.916, -9.128]]]) | ||
|
||
## Landsat 7 Collection | ||
l7=ee.ImageCollection('LANDSAT/LE07/C01/T1_SR').filterDate('1999-01-01', '2018-09-30').filterBounds(geom) | ||
|
||
def exportCollectionToDrive (userCollection,folderName): | ||
userCollection2=userCollection#.map(toals) | ||
imageList = ee.List(userCollection2.toList(userCollection2.size().add(1))) | ||
length = userCollection2.size().getInfo() | ||
print(length) | ||
|
||
|
||
def exportImage(img): | ||
fileName = ee.String(img.get('system:index')).getInfo() | ||
fileGeometry = geom.bounds().getInfo()['coordinates'][0] | ||
band=ee.Image(img).bandNames().get(0) | ||
sc=30 ##pixel size | ||
|
||
## Masking | ||
cloud=img.select('pixel_qa').bitwiseAnd(32).neq(0) | ||
img=img.updateMask(cloud.Not()) | ||
cloud_shadow = img.select('pixel_qa').bitwiseAnd(8).neq(0) | ||
img=img.updateMask(cloud_shadow.Not()) | ||
|
||
##Check overlap | ||
area=ee.Feature(geom).geometry().area() | ||
imgarea=ee.Image(img).multiply(0).add(1).clip(geom).reduceRegion( | ||
reducer= ee.Reducer.sum().unweighted(), | ||
geometry= geom, | ||
maxPixels= 1e12, | ||
tileScale= 1, | ||
scale=30) | ||
imgp=ee.Number(imgarea.get(band)).multiply(sc).multiply(sc).divide(area) | ||
|
||
##Check for overlap | ||
if imgp.getInfo()>=0.7: | ||
task = ee.batch.Export.image.toDrive( | ||
image = img.normalizedDifference(['B4', 'B3']).rename('NDVI').toFloat(), | ||
description = fileName, | ||
folder = 'gee-collection-acre-landsat7', | ||
maxPixels = 1e13, | ||
region = fileGeometry, | ||
scale = 30) | ||
task.start() | ||
|
||
|
||
index = 0 | ||
while index < length: | ||
print("Export #: " + str(index+1)) | ||
img2export = ee.Image(imageList.get(index)) | ||
exportImage(img2export) | ||
index = index + 1 | ||
time.sleep(1) # sleep for 1 seconds | ||
|
||
print('Finished exporting data') | ||
print('') | ||
exportCollectionToDrive(userCollection=l7, folderName="gee-collection-acre-landsat7") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
import oauth2client | ||
import ee | ||
|
||
ee.Initialize() | ||
|
||
## Polygon area for extraction | ||
geom=ee.Geometry.Polygon( | ||
[[[-72.050, -9.128], | ||
[-72.050, -9.235], | ||
[-71.916, -9.235], | ||
[-71.916, -9.128]]]) | ||
|
||
l8=ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterDate('2013-01-01', '2018-08-30').filterBounds(geom) | ||
|
||
def exportCollectionToDrive (userCollection,folderName): | ||
userCollection2=userCollection#.map(toals) | ||
imageList = ee.List(userCollection2.toList(userCollection2.size().add(1))) | ||
length = userCollection2.size().getInfo() | ||
print(length) | ||
|
||
def exportImage(img): | ||
fileName = ee.String(img.get('system:index')).getInfo() | ||
fileGeometry = geom.bounds().getInfo()['coordinates'][0] | ||
task = ee.batch.Export.image.toDrive( | ||
image = img.normalizedDifference(['B5', 'B4']).rename('NDVI').toFloat(), | ||
description = fileName, | ||
folder = 'gee-collection-acre-landsat8', | ||
maxPixels = 1e13, | ||
region = fileGeometry, | ||
scale = 30) | ||
task.start() | ||
|
||
index = 0 | ||
while index < length: | ||
print("Export #: " + str(index+1)) | ||
img2export = ee.Image(imageList.get(index)) | ||
exportImage(img2export) | ||
index = index + 1 | ||
time.sleep(5) | ||
|
||
print('Finished exporting data') | ||
print('') | ||
exportCollectionToDrive(userCollection=l8, folderName="gee-collection-acre-landsat8") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
import oauth2client | ||
import ee | ||
|
||
ee.Initialize() | ||
|
||
## Polygon area for extraction | ||
## Polygon area for extraction | ||
geom=ee.Geometry.Polygon( | ||
[[[21.870, -18.730], | ||
[21.870, -19.510], | ||
[22.840, -19.510], | ||
[22.840, -18.730]]]) | ||
|
||
## Landsat 5 Collection | ||
l5=ee.ImageCollection('LANDSAT/LT05/C01/T1_SR').filterDate('1984-01-01', '1997-12-31').filterBounds(geom) | ||
|
||
def exportCollectionToDrive (userCollection,folderName): | ||
userCollection2=userCollection#.map(toals) | ||
imageList = ee.List(userCollection2.toList(userCollection2.size().add(1))) | ||
length = userCollection2.size().getInfo() | ||
print(length) | ||
|
||
|
||
def exportImage(img): | ||
fileName = ee.String(img.get('system:index')).getInfo() | ||
fileGeometry = geom.bounds().getInfo()['coordinates'][0] | ||
band=ee.Image(img).bandNames().get(0) | ||
sc=30 ##pixel size | ||
|
||
## Masking | ||
cloud=img.select('pixel_qa').bitwiseAnd(32).neq(0) | ||
img=img.updateMask(cloud.Not()) | ||
cloud_shadow = img.select('pixel_qa').bitwiseAnd(8).neq(0) | ||
img=img.updateMask(cloud_shadow.Not()) | ||
|
||
##Check overlap | ||
area=ee.Feature(geom).geometry().area() | ||
imgarea=ee.Image(img).multiply(0).add(1).clip(geom).reduceRegion( | ||
reducer= ee.Reducer.sum().unweighted(), | ||
geometry= geom, | ||
maxPixels= 1e12, | ||
tileScale= 1, | ||
scale=30) | ||
imgp=ee.Number(imgarea.get(band)).multiply(sc).multiply(sc).divide(area) | ||
|
||
##Check for overlap | ||
if imgp.getInfo()>=0.8: | ||
task = ee.batch.Export.image.toDrive( | ||
image = img.normalizedDifference(['B4', 'B3']).rename('NDVI').toFloat(), | ||
description = fileName, | ||
folder = 'gee-collection-okavango-landsat5', | ||
maxPixels = 1e13, | ||
region = fileGeometry, | ||
scale = 30) | ||
task.start() | ||
|
||
|
||
index = 0 | ||
while index < length: | ||
print("Export #: " + str(index+1)) | ||
img2export = ee.Image(imageList.get(index)) | ||
exportImage(img2export) | ||
index = index + 1 | ||
time.sleep(1) # sleep for 1 seconds | ||
|
||
print('Finished exporting data') | ||
print('') | ||
exportCollectionToDrive(userCollection=l5, folderName="gee-collection-okavango-landsat5") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
import oauth2client | ||
import ee | ||
|
||
ee.Initialize() | ||
|
||
## Polygon area for extraction | ||
geom=ee.Geometry.Polygon( | ||
[[[21.870, -18.730], | ||
[21.870, -19.510], | ||
[22.840, -19.510], | ||
[22.840, -18.730]]]) | ||
|
||
## Landsat 7 Collection | ||
l7=ee.ImageCollection('LANDSAT/LE07/C01/T1_SR').filterDate('1999-01-01', '2018-09-30').filterBounds(geom) | ||
|
||
def exportCollectionToDrive (userCollection,folderName): | ||
userCollection2=userCollection#.map(toals) | ||
imageList = ee.List(userCollection2.toList(userCollection2.size().add(1))) | ||
length = userCollection2.size().getInfo() | ||
print(length) | ||
|
||
|
||
def exportImage(img): | ||
fileName = ee.String(img.get('system:index')).getInfo() | ||
fileGeometry = geom.bounds().getInfo()['coordinates'][0] | ||
band=ee.Image(img).bandNames().get(0) | ||
sc=30 ##pixel size | ||
|
||
## Masking | ||
cloud=img.select('pixel_qa').bitwiseAnd(32).neq(0) | ||
img=img.updateMask(cloud.Not()) | ||
cloud_shadow = img.select('pixel_qa').bitwiseAnd(8).neq(0) | ||
img=img.updateMask(cloud_shadow.Not()) | ||
|
||
##Check overlap | ||
area=ee.Feature(geom).geometry().area() | ||
imgarea=ee.Image(img).multiply(0).add(1).clip(geom).reduceRegion( | ||
reducer= ee.Reducer.sum().unweighted(), | ||
geometry= geom, | ||
maxPixels= 1e12, | ||
tileScale= 1, | ||
scale=30) | ||
imgp=ee.Number(imgarea.get(band)).multiply(sc).multiply(sc).divide(area) | ||
|
||
##Check for overlap | ||
if imgp.getInfo()>=0.7: | ||
task = ee.batch.Export.image.toDrive( | ||
image = img.normalizedDifference(['B4', 'B3']).rename('NDVI').toFloat(), | ||
description = fileName, | ||
folder = 'gee-collection-okavango-landsat7', | ||
maxPixels = 1e13, | ||
region = fileGeometry, | ||
scale = 30) | ||
task.start() | ||
|
||
|
||
index = 0 | ||
while index < length: | ||
print("Export #: " + str(index+1)) | ||
img2export = ee.Image(imageList.get(index)) | ||
exportImage(img2export) | ||
index = index + 1 | ||
time.sleep(1) # sleep for 1 seconds | ||
|
||
print('Finished exporting data') | ||
print('') | ||
exportCollectionToDrive(userCollection=l7, folderName="gee-collection-okavango-landsat7") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
import oauth2client | ||
import ee | ||
|
||
ee.Initialize() | ||
|
||
geom=ee.Geometry.Polygon( | ||
[[[21.870, -18.730], | ||
[21.870, -19.510], | ||
[22.840, -19.510], | ||
[22.840, -18.730]]]) | ||
|
||
l8=ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterDate('2013-01-01', '2018-08-30').filterBounds(geom) | ||
|
||
def exportCollectionToDrive (userCollection,folderName): | ||
userCollection2=userCollection#.map(toals) | ||
imageList = ee.List(userCollection2.toList(userCollection2.size().add(1))) | ||
length = userCollection2.size().getInfo() | ||
print(length) | ||
|
||
def exportImage(img): | ||
fileName = ee.String(img.get('system:index')).getInfo() | ||
fileGeometry = geom.bounds().getInfo()['coordinates'][0] | ||
task = ee.batch.Export.image.toDrive( | ||
image = img.normalizedDifference(['B5', 'B4']).rename('NDVI').toFloat(), | ||
description = fileName, | ||
folder = 'gee-collection-okavango-landsat8', | ||
maxPixels = 1e13, | ||
region = fileGeometry, | ||
scale = 30) | ||
task.start() | ||
|
||
index = 0 | ||
while index < length: | ||
print("Export #: " + str(index+1)) | ||
img2export = ee.Image(imageList.get(index)) | ||
exportImage(img2export) | ||
index = index + 1 | ||
time.sleep(5) | ||
|
||
print('Finished exporting data') | ||
print('') | ||
exportCollectionToDrive(userCollection=l8, folderName="gee-collection-okavango-landsat8") |
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
Oops, something went wrong.