In this article, we will learn how to work with a Jupyter Notebook within EarthAI.
Jupyter Notebooks are documents that combine executable code with accompanying text, images, and interactive visualizations. Notebooks are a native component to EarthAI. For this article, we will demonstrate the basics of working with notebooks within the EarthAI platform. Although this example makes use of EarthAI's proprietary software, the mechanics of working with Jupyter Notebooks presented here are generic to notebooks outside of the platform.
After launching an EarthAI Notebook server, you can view the contents of the examples directory in the file browser located in the left sidebar and choose an existing notebook (with file extension ".ipynb"), or create a new notebook as demonstrated in this article. For the sake of simplicity, we will use an existing notebook.
Double-click on the folder names to navigate to examples -> getting-started. Double-click on "quick-example-1.ipynb" to open this notebook. The notebook will open up in the main work area as shown below.
This example notebook queries MODIS imagery, calculates NDVI, and visualizes the results.
The first cell of the notebook imports the libraries necessary to run the code in this following cells. The cells must be run in order because there are dependencies between cells. To run the first cell, click on the cell and then you can either hit Shift+Enter on your keyboard or click the play button at the top of the notebook (circled in red below).
You can read through the text in the notebook to understand what the code is doing and run each cell. To run all of the cells at once you can click Run in the top menu and select Run All Cells. There are other options in the Run menu that you can play around with.
To add a new cell to your notebook, select the plus sign button (circled in red below) at the top of the notebook.
To delete a cell, right click on a cell and select Delete Cells or go to Edit in the top menu and select Delete Cells.
If you’ve made a mistake in one of your cells or it's taking a while to run and you want to stop it, you can select the square button (circled in red below) at the top of the notebook, which will interrupt the kernel and stop the execution of the cell. If you want to shut down the notebook completely, you can select Kernel in the top menu and select Shutdown Kernel. By doing this, you will lose any cached results in the notebook.
To save your notebook, select the floppy disk save icon (circled in red below) at the top of the notebook.
Throughout this notebook you’ve probably noticed some of the cells have Python code and some are Markdown code. Any new cell added will be Python code by default. You can change the cell type by clicking on the cell and clicking the dropdown at top of the notebook (outlined in red below) and selecting a different cell type option.
To close a notebook, you can click the red X (circled in red below) next to the notebook name. Closing the notebook will not shut down the kernel though, you will need to right click on notebook in the file browser and select Shut Down Kernel or select Kernel -> Shut Down Kernel in the top menu before closing the notebook. Shutting down the kernel will free up memory on your server but will also remove any cached variables in your notebook.
Below are some additional online resources for those who would like to learn more about the underlying technology that supports EarthAI. These are not required reading to be able to start working in the platform.