Skip to content

Get started with Jupyter notebooks

Jupyter notebooks provide an interactive environment for writing and running code, combining text, code, and visualizations in a single document. They are widely used for data analysis, workflow prototyping, and scientific computing, making them a powerful tool for working with GRASS.

The grass.jupyter Python package provides a Jupyter notebook interface to GRASS. It includes modules for creating map figures, interactive web maps, visualizing data series and time series, and generating 3D visualizations.

To get started with grass.jupyter, import the package, and start a GRASS session with the gj.init function:

import grass.jupyter as gj

session = gj.init("path/to/my_project")

All classes and functions for interaction in notebooks are now available under gj, for example we can display a map with a selected raster and vector:

# Create a new map
m = gj.Map()

# Add a raster map to the map object
m.d_rast(map="elevation")

# Add a vector map to the map object
m.d_vect(map="streets", color="black")

# Display the map
m.show()

Elevation map overlayed with streets with gj.Map

Continue exploring the grass.jupyter package capabilities with more examples or run the Jupyter tutorial on Binder:

Binder

Python library documentation

For complete documentation on the grass.jupyter package, see the grass.jupyter library documentation page.

Tutorials

SOURCE CODE

Available at: jupyter_get_started source code (history)
Latest change: Tuesday Apr 01 14:34:28 2025 in commit 4f40ade