Skip to content

Conversation

@wenzeslaus
Copy link
Member

This improves how computational region is handled in all NumPy examples. Specifically, it creates variables for number of rows and columns and only then sets the computational region to be clear what is happening.

tools = Tools(session=session)
rows = elevation.shape[0]
cols = elevation.shape[1]
tools.g_region(s=0, n=rows, w=0, e=cols, res=1)

This still has limited applicability as it works without a geographical context. Notably, NumPy arrays are generally not georeferenced, so XY project is applicable and I added creation of the project to the example. Maybe this is enough for the basic example.

While this builds on #6313 (and currently contains also the changes from there), I'm opening a separate PR to allow for a separate discussion on how to handle this.

The main interface doc for Python now shows how GRASS tools are used with arrays through grass.tools before showing direct conversions between GRASS rasters and NumPy arrays with grass.script.array.
@github-actions github-actions bot added Python Related code is in Python libraries docs markdown Related to markdown, markdown files labels Sep 5, 2025
tools = Tools()
tools.g_region(n=elevation_array.shape[0], s=0,
e=elevation_array.shape[1], w=0, res=1)
gs.create_project("xy_project")
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing comment here.

@wenzeslaus wenzeslaus added this to the 8.5.0 milestone Oct 6, 2025
@echoix echoix added the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts/needs rebase Rebase to or merge with the latest base branch is needed docs libraries markdown Related to markdown, markdown files Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants