Difference between revisions of "GRASS GIS Jupyter notebooks"

From GRASS-Wiki
Jump to navigation Jump to search
m (grass7x -> grass78)
(+ RISE: Jupyter/IPython Slideshow Extension, https://rise.readthedocs.io/en/stable/)
Line 84: Line 84:

* [https://github.com/wenzeslaus/gdoc2py GRASS GIS focused converter from HTML with pre code tags to Jupyter Notebook]
* [https://github.com/wenzeslaus/gdoc2py GRASS GIS focused converter from HTML with pre code tags to Jupyter Notebook]
* RISE: Jupyter/IPython Slideshow Extension, https://rise.readthedocs.io/en/stable/

[[Category: Documentation]]
[[Category: Documentation]]
[[Category: Python]]
[[Category: Python]]
[[Category: Tutorial]]
[[Category: Tutorial]]

Revision as of 14:55, 7 February 2021

A Jupyter Notebook is a web application that allows you to create and share documents that contain scripts and code, equations, visualizations and explanatory text, combined.

List of selected GRASS GIS Jupyter notebooks

(please expand!)

Running a Jupyter notebook locally

You can even change the code and explore your modified script(s).


You need to have a working Jupyter installation:

pip install jupyter

How to run GRASS GIS from Jupyter notebook

(this section needs to be updated)

Running GRASS from Jupyter notebook requires that Jupyter notebook is installed on your system, and that you set up the environment variables for using GRASS.

For example you can create a script called grass_jupyter.sh that contains the following lines:

# directory where GRASS GIS lives
export GISBASE=`grass78 --config path`   # or define path to binaries like /usr/local/grass-7.8.dev

# generate GISRC
# Defines the system wide value while in a GRASS session
MYGISDBASE=$HOME/grassdata # Change this path to reflect your own 
MYLOC=MyLoc # Change this location name to reflect your own 

# Set the global grassrc file to individual file name

echo "GRASS_GUI: text" >> "$MYGISRC"

# path to GRASS settings file

export PATH=$GISBASE/bin:$GISBASE/scripts:$PATH

# start the notebook in the notebook folder
cd $HOME/notebooks # change to notebooks folder (example; update to your path)

nohup jupyter notebook --ip= --port=8888 --debug &

To easily use this script, add this line to your $HOME/.bashrc file:

# update path to script accordingly
alias grass_notebook='sh $HOME/grass_jupyter.sh'

From terminal, in your home directory:

source .bashrc

Now you can start easily your notebook typing in the terminal: