Get Results from Google Drive¶
This notebook demos how to automatically get results from Google Drive. Prior to running, you have to install pydrive and follow the authentication steps to link your Google Drive account.
Follow the instructions to obtain a client configuration file client_secrets.json
.
One additional step required is go to Audience and add your email as a test user. Otherwise, you will have to publish the application.
Place the client_secrets.json
file in a folder such that the authenticateGoogleDrive()
function can find it. By default the function looks for the file in ~/.config/creds/client_secrets.json
. You can change this by passing the creds_dir
argument to the function.
In [ ]:
Copied!
# !pip install gee_zonal pydrive
# !pip install gee_zonal pydrive
In [2]:
Copied!
import ee
from gee_zonal import ZonalStats, authenticateGoogleDrive
import ee
from gee_zonal import ZonalStats, authenticateGoogleDrive
In [ ]:
Copied!
drive = authenticateGoogleDrive()
drive = authenticateGoogleDrive()
In [ ]:
Copied!
gaul_adm1 = ee.FeatureCollection("projects/sat-io/open-datasets/FAO/GAUL/GAUL_2024_L1")
AOIs_AFR = gaul_adm1.filterMetadata("continent", "equals", "Africa")
gaul_adm1 = ee.FeatureCollection("projects/sat-io/open-datasets/FAO/GAUL/GAUL_2024_L1")
AOIs_AFR = gaul_adm1.filterMetadata("continent", "equals", "Africa")
In [ ]:
Copied!
zs = ZonalStats(
collection_id="UCSB-CHG/CHIRPS/PENTAD",
target_features=AOIs_AFR,
statistic_type="mean",
frequency="annual",
temporal_stat="sum",
scale=5000,
output_dir="africa",
output_name="precipitation",
)
zs = ZonalStats(
collection_id="UCSB-CHG/CHIRPS/PENTAD",
target_features=AOIs_AFR,
statistic_type="mean",
frequency="annual",
temporal_stat="sum",
scale=5000,
output_dir="africa",
output_name="precipitation",
)
In [ ]:
Copied!
zs.runZonalStats()
zs.runZonalStats()
In [ ]:
Copied!
zs.reportRunTime()
zs.reportRunTime()
In [17]:
Copied!
df = zs.getZonalStats(drive)
df = zs.getZonalStats(drive)
In [ ]:
Copied!
df.head()
df.head()