Skip to content

Tutorial: getting started with conda#116

Open
baharmon wants to merge 10 commits into
OSGeo:mainfrom
baharmon:conda
Open

Tutorial: getting started with conda#116
baharmon wants to merge 10 commits into
OSGeo:mainfrom
baharmon:conda

Conversation

@baharmon

@baharmon baharmon commented May 6, 2026

Copy link
Copy Markdown
Contributor

A new quick start tutorial on GRASS for Conda. Covers installing the miniforge distribution of Conda, creating an environment for GRASS and Jupyter, downloading the Natural Earth Dataset, and then displaying maps in a Jupyter Notebook. This pull request should be merged after PR #115 since it expects acm.csl to be in the root directory.

@baharmon baharmon changed the title tutorial: getting started with conda Tutorial: getting started with conda May 6, 2026
Comment on lines +201 to +202
# Set GRASS database
gisdbase = Path.home() / "grassdata"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's omit using gisdbase and grassdata... We are trying to put projects in the spotlight and avoid the traditional directory structure. We can have projects anywhere, so perhaps just download the zip in the current directory, no need to create a grassdata for a zip file.

@baharmon baharmon May 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veroandreo Okay. gs.setup.init and gj.init require a project path though. So I think I need to include a path in the call: session = gj.init(Path.cwd() / "natural_earth_dataset"). Is there a better way?

Alternatively, we could create a temporary directory and project like in many of the other tutorials. Perhaps just using the current directory, however, is a little simpler and an example of a different way to work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, either a path to the project (and it'll start the session in PERMANENT) or a directory (be it temporary, current or grassdata) + project name, so: session = gj.init(Path.cwd(), "natural_earth_dataset"). You could also do:

home = Path.cwd()
project = "natural_earth_dataset"
session = gj.init(home, project)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the latter; it is very clear.

Comment on lines +104 to +107
For {{< fa brands microsoft >}} Windows,
download and run the binary installer.
See [here](https://github.com/conda-forge/miniforge#install)
for more detailed instructions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we wait to merge this tutorial until the conda package for Windows is ready? Or maybe we say something like "Conda package for Windows is coming soon!"?

@baharmon baharmon May 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veroandreo After some reflection, I think I'd prefer publishing this now and then updating it. I commented out the Windows instructions and replaced it with a coming soon statement. I don't know how long it will be before the Windows package is released. When GRASS 8.5 for Conda is out, I will update the tutorial to use the new GRASS Tools API. I also plan to write another, more in-depth tutorial.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meanwhile, we now have conda package for Windows too :)

@baharmon

Copy link
Copy Markdown
Contributor Author

I removed the citation style from this tutorial's frontmatter as it will be set in the project's yaml file. See 5fc178d.

@baharmon baharmon requested a review from veroandreo May 31, 2026 17:34

@Valyrian-Code Valyrian-Code left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, clear quickstart — the structure (Manager → Environment → Notebook) reads really well, and the {{< meta links.* >}} pattern plus format: ipynb output are great. I tested the links and the dataset download; almost everything checks out. One thing that would break the setup for a new user, and a few small suggestions:

One required fix before merge

The conda install step installs into the wrong environment.

conda create --name grass
conda install grass jupyterlab
conda activate grass

conda create --name grass creates the env but doesn't activate it, so conda install grass jupyterlab installs into the currently-active base env rather than grass. conda activate grass then switches to the still-empty env, and the later jupyter lab won't be found. Activating before installing fixes it:

conda create --name grass
conda activate grass
conda install grass jupyterlab

(The one-liner just below — conda create -n grass grass jupyterlab && conda activate grass — is already correct.)

Suggestions (non-blocking)

  • grass_projects link uses grass-devel (in the frontmatter links: block). #124 moved the repo to grass-stable; the page exists on stable too, so switching keeps it consistent and stable across releases.
  • requests isn't in the install list — it's imported in the notebook but only grass jupyterlab are installed. It usually comes in transitively via jupyterlab_server, but adding requests to the conda install (or using stdlib urllib.request) makes the notebook self-contained.
  • Two small typos: "We will using scripting" → "We will use scripting"; "open an new Jupyter notebook" → "a new".
  • date: last-modified — other tutorials use an explicit date: (plus date-modified: today); since the homepage listing sorts by date, an explicit date is a bit more predictable.

With the environment ordering fixed this is good to go from my side. Thanks for putting this together!

@baharmon

baharmon commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Refactored for the GRASS Tools API.

@Valyrian-Code Valyrian-Code left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround — all my earlier points are addressed (env ordering, requests, grass-stable link, typos, and the date). Nice touch refactoring to the grass.tools API too; moving off the deprecated g.proj -g flag to format="shell" matches what the manual now recommends. I checked and grass.tools is documented on grass-stable, so it'll resolve in the conda release.

One tiny, non-blocking thing: now that both gs.run_command(...) calls are tools.*, import grass.script as gs is unused and could be dropped.

LGTM otherwise — thanks for putting this together! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants