Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now it is possible to download NDVI and EVI data from Google Earth Engine #42

Merged
merged 2 commits into from
May 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 33 additions & 50 deletions downloader_app/tiff_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def download_tiffs(source, dates, point1, point2, opt=False):

# Obtains the frequency of source.
freq = source_freq(source)
delta = datetime.timedelta(days=int(freq[0]))
delta = datetime.timedelta(days=freq)

# Download maps by date.
length = len(dates)
Expand Down Expand Up @@ -517,40 +517,34 @@ def single_download_gee(source, date1, date2, x1, x2, y1, y2, opt):
elif source == "CHIRPS":
scale = 5000
CHIRPS = ee.ImageCollection("UCSB-CHG/CHIRPS/PENTAD")
img = (
CHIRPS.filterDate(date1, date2)
.sort("system:time_start", False)
.mean()
.rename("Precipitation")
.set("date", date1)
.set("system:time_start", date1)
)

elif source == "NDVI":
scale = 500
img = CHIRPS.filterDate(date1, date2) \
.sort('system:time_start', False) \
.mean() \
.rename("Precipitation") \
.set('date', date1) \
.set('system:time_start', date1)

elif source == 'NDVI':
scale = 5000
MYD13Q1 = ee.ImageCollection("MODIS/006/MYD13Q1")
img = (
MYD13Q1.filterDate(date1, date2)
.sort("system:time_start", False)
.select(source)
.mean()
.rename(source)
.set("date", date1)
.set("system:time_start", date1)
)

elif source == "EVI":
scale = 500
img = MYD13Q1.filterDate(date1, date2) \
.sort('system:time_start', False) \
.select(source) \
.mean() \
.rename("NDVI") \
.set('date', date1) \
.set('system:time_start', date1)

elif source == 'EVI':
scale = 5000
MYD13Q1 = ee.ImageCollection("MODIS/006/MYD13Q1")
img = (
MYD13Q1.filterDate(date1, date2)
.sort("system:time_start", False)
.select(source)
.mean()
.rename(source)
.set("date", date1)
.set("system:time_start", date1)
)
img = MYD13Q1.filterDate(date1, date2) \
.sort('system:time_start', False) \
.select(source) \
.mean() \
.rename("EVI") \
.set('date', date1) \
.set('system:time_start', date1)

# Prepare parameters.
filename = source + "-" + str(year1) + "-" + str(month1) + "-" + str(day1)
Expand Down Expand Up @@ -946,24 +940,13 @@ def source_freq(source):
"""

if source == "chirps-2.0":
freq = "1D"
freq = 1
elif source == "CHIRPS":
freq = "5D"
elif source in [
"LandDAAC-v5-day",
"LandDAAC-v5-night",
"LST_Day_1km",
"LST_Night_1km",
]:
freq = "8D"
elif source in [
"LandDAAC-v6-EVI",
"LandDAAC-v6-NDVI",
"LandDAAC-v6-view_zenith_angle",
"NDVI",
"EVI",
]:
freq = "16D"
freq = 5
elif source in ["LandDAAC-v5-day", "LandDAAC-v5-night", "LST_Day_1km", "LST_Night_1km"]:
freq = 8
elif source in ["LandDAAC-v6-EVI", "LandDAAC-v6-NDVI", "LandDAAC-v6-view_zenith_angle", "NDVI", "EVI"]:
freq = 16

return freq

Expand Down