project logo

Jupyter Notebook Quickstart

The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.

This Quick Start describes how to:

  • start a jupyter notebook server
  • load a jupyter notebook
  • interact with python code and javascript widgets

Start the jupyter server

From the application launch menu in the lower left corner.

  • Choose Geospatial -> Spatial Tools -> Start Jupyter Notebook
../../_images/jupyter1-1.png

A terminal window will open and a startup log will begin to scroll.

  • Choose Geospatial -> Spatial Tools -> Jupyter Notebook
../../_images/jupyter1-2.png

A web browser is launched showing the notebook dashboard.

../../_images/jupyter1-3.png

From the notebook dashboard you can navigate the directory tree, start new notebooks, create files and directories, as well as rename, delete and upload files.

Open and execute an existing notebook

Let’s open an existing notebook. From the main page click on the directory GSOC.

../../_images/jupyter2.png

Choose the Introduction notebook.

../../_images/jupyter3.png

This is a simple notebook, which contains text and links, like a HTML web page.

Then under “Simple-web-gis-products” select “CESIUM”.

../../_images/jupyter4.png

Here there are a series of example using the cesium javascript library. Let’s click on “CesiumWidget Interact-Example”, which uses the widget extension, some python libraries and cesium-js.

From the toolbar on top of the notebook chose: cell->run all. If everything worked as planned you should be able to see the results at the bottom of the page.

../../_images/jupyter5.png

Change code

Now lets change some of the code:

In the code cell in [8] we generated a python dictionary based on some keywords (location names) with empty values:

in [8]:  myplace = {'Eboli, IT':'', 'Woods Hole, MA':'', 'Durham, NH':''}

and at the code input cell in [9], we loop over the dictionary keys and making use of a geocoding library geocoder, we add the location information inside the previously created python dictionary my place:

in [9]: import geocoder
        import time
        for i in myplace.keys():
            g = geocoder.google(i)
            print(g.latlng)
            myplace[i]=g.latlng

Try to add or replace new keywords like we did in In [8]

in []:  mynewplace = {'Cairns, AU':'', 'Cooktown, AU':'', 'Darvin, AU':''}

and re run In [9] [10] [11] you will see the newly created dictionary is now used in the drop down menu to select the new location and zoom-to withing the Cesium globe.

What Next?

For more information about the jupyter notebook, please refer to the jupyter official documentation. More notebook examples are available from the notebook root directory. For a quick introduction on how to use the jupyter-notebook interface, from the start page, check the notebook: “Introduction to jupyter notebook”

Copyright & Disclaimer