First, we need to mount the engine with google drive folder. Click the "Run" button of the code cell
Click on the URL that appears, select your Google account, and allow the app to mount. Copy the authorization code and enter it in the notebook prompt.
Run the next cell to install pyshp package
Run the next cell to import all libraries. When you import "WaPOR" module for the first time, you will be asked to enter WaPOR API token. Go to your WaPOR profile (My WaPOR>My Profile) and generate an API token. Copy and keep this token somewhere safe (e.g. a note file). Enter this token in the notebook prompt.
Run the next two cells to read the extent of the study area from a shapefile. This will also plot the shapefile so that you can check how the shape looks like.
In this example, we're using the shapefile of sugarcane field in Xinavane, Mozambique, which path is: "/content/drive/My Drive/WAPORWP/Data/1Boundary/Shapefile/Xinavane_1.shp".
When you do the analyses for your own study area, you will need to upload the shapefile of the new area to Google Drive and change this path name.
Google Colab notebooks have an idle timeout of 90 minutes and absolute timeout of 12 hours. This means, if user does not interact with his Google Colab notebook for more than 90 minutes, its instance is automatically terminated. Also, maximum lifetime of a Colab instance is 12 hours. Therefore, to avoid timeout when you need to run the scripts for a long time on the cloud, you can do these following steps
In Google Chrome window, press Ctrl+Shift+I to open Developer tools. Under Console tab, copy and paste the following script and enter:
document.querySelector("#comments > span").click()