GRASS GIS Jupyter notebooks: Difference between revisions
Veroandreo (talk | contribs) (+ Jupyter notebook) |
m (grass7x -> grass78) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
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. | 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!)'' | |||
* https://github.com/wenzeslaus/try-grass-in-jupyter | |||
* https://github.com/wenzeslaus/try-grass-in-jupyter-with-bash | |||
* [https://github.com/wenzeslaus/geospatial-modeling-course-jupyter/tree/master/notebooks 14 Jupyter Notebooks for learning geospatial analysis and modeling with GRASS GIS] | |||
* [https://github.com/tgrippa/Opensource_OBIA_processing_chain An open-source semi-automated processing chain for urban OBIA classification] | |||
* [https://github.com/zarch/workshop-pygrass Workshop on PyGRASS using IPython notebook] | |||
* [https://github.com/wenzeslaus/python-grass-addon How to write a Python GRASS GIS 7 addon] | |||
* [https://github.com/lucadelu/docker-stacks/tree/geospatial/geospatial-notebook Jupyter Notebook Geospatial Python Stack] | |||
* [https://gist.github.com/joergsteinkamp/43fb13a82aeab9b5c0dcc4433f97f1a6 Simple Opensource GIS examples with GRASS GIS and R] | |||
== Running a Jupyter notebook locally == | |||
You can even change the code and explore your modified script(s). | You can even change the code and explore your modified script(s). | ||
== How to run GRASS GIS from Jupyter notebook == | === Requirements === | ||
You need to have a working Jupyter installation: | |||
<source lang="bash"> | |||
pip install jupyter | |||
</source> | |||
=== 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 [https://grass.osgeo.org/grass78/manuals/variables.html environment variables] for using GRASS. | |||
For example you can create a '''script''' called <tt>grass_jupyter.sh</tt> that contains the following lines: | |||
<source lang="bash"> | <source lang="bash"> | ||
# directory where GRASS lives | # directory where GRASS GIS lives | ||
export GISBASE=/usr/local/grass-7. | export GISBASE=`grass78 --config path` # or define path to binaries like /usr/local/grass-7.8.dev | ||
echo $GISBASE | |||
# generate GISRC | # generate GISRC | ||
Line 34: | Line 59: | ||
# start the notebook in the notebook folder | # start the notebook in the notebook folder | ||
cd $HOME/notebooks # change | cd $HOME/notebooks # change to notebooks folder (example; update to your path) | ||
nohup jupyter notebook --ip=0.0.0.0 --port=8888 --debug & | nohup jupyter notebook --ip=0.0.0.0 --port=8888 --debug & | ||
</source> | </source> | ||
To easily use this script, add this line to your <tt>$HOME/.bashrc</tt> file: | |||
<source lang="bash"> | <source lang="bash"> | ||
alias grass_notebook='sh grass_jupyter.sh' | # update path to script accordingly | ||
alias grass_notebook='sh $HOME/grass_jupyter.sh' | |||
</source> | </source> | ||
Line 51: | Line 76: | ||
</source> | </source> | ||
Now you can start your notebook typing in the terminal: | Now you can start easily your notebook typing in the terminal: | ||
<source lang="bash"> | <source lang="bash"> | ||
grass_notebook | grass_notebook | ||
</source> | </source> | ||
=== | ==== Tools ==== | ||
* [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] |
Revision as of 19:58, 30 August 2020
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!)
- https://github.com/wenzeslaus/try-grass-in-jupyter
- https://github.com/wenzeslaus/try-grass-in-jupyter-with-bash
- 14 Jupyter Notebooks for learning geospatial analysis and modeling with GRASS GIS
- An open-source semi-automated processing chain for urban OBIA classification
- Workshop on PyGRASS using IPython notebook
- How to write a Python GRASS GIS 7 addon
- Jupyter Notebook Geospatial Python Stack
- Simple Opensource GIS examples with GRASS GIS and R
Running a Jupyter notebook locally
You can even change the code and explore your modified script(s).
Requirements
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
echo $GISBASE
# 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 to notebooks folder (example; update to your path)
nohup jupyter notebook --ip=0.0.0.0 --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:
grass_notebook