GRASS GIS Jupyter notebooks
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.
You can even change the code and explore your modified script(s).
How to run GRASS GIS from Jupyter notebook
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 lives export GISBASE=/usr/local/grass-7.3.svn # Change this path to reflect your own # 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 MYMAPSET=PERMANENT # Set the global grassrc file to individual file name MYGISRC="$HOME/.grassrc.$$" echo "GISDBASE: $MYGISDBASE" > "$MYGISRC" echo "LOCATION_NAME: $MYLOC" >> "$MYGISRC" echo "MAPSET: $MYMAPSET" >> "$MYGISRC" echo "GRASS_GUI: text" >> "$MYGISRC" # path to GRASS settings file export GISRC=$MYGISRC export LD_LIBRARY_PATH=$GISBASE/lib:$LD_LIBRARY_PATH export PYTHONPATH=$GISBASE/etc/python:$PYTHONPATH export PATH=$GISBASE/bin:$GISBASE/scripts:$PATH # start the notebook in the notebook folder cd $HOME/notebooks # change this path to reflect your own path to notebooks folder nohup jupyter notebook --ip=0.0.0.0 --port=8888 --debug &
Add this line to your $HOME/.bashrc file:
alias grass_notebook='sh grass_jupyter.sh'
From terminal, in your home directory:
Now you can start your notebook typing in the terminal:
List of selected GRASS GIS Jupyter notebooks
- OSGeoLive-Notebooks: Introduction to GRASS GIS
- Workshop on pygrass using IPython notebook
- An open-source semi-automated processing chain for urban OBIA classification
- How to write a Python GRASS GIS 7 addon
- 14 Jupyter Notebooks for learning geospatial analysis and modeling with GRASS GIS