Skip to content

Commit 4756bd5

Browse files
committed
docker: update grass-session to use tools
Replace old python interface with new tools interface
1 parent a12020a commit 4756bd5

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

docker/testdata/test_grass_session.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
# Import GRASS Python bindings (requires 8.4+) and test r.in.pdal
22

33
# PYTHONPATH=$(grass --config python-path) python
4+
# or
5+
# export PYTHONPATH=$(grass --config python-path)
46

57
import grass.script as gs
8+
from grass.tools import Tools
69

7-
# full path to new project
8-
project = "/tmp/grasstest_epsg_25832"
9-
gs.create_project(project, epsg="25832")
10-
10+
# Create a new project (formerly "location")
1111
# hint: do not use ~ as an alias for HOME
12-
with gs.setup.init(project):
12+
project = "/tmp/my_project_3358"
13+
gs.create_project(project, epsg="3358")
14+
15+
# Initialize the GRASS session
16+
with gs.setup.init(project) as session:
1317
print("GRASS session: tests for PROJ, GDAL, PDAL, GRASS")
1418
print(gs.parse_command("g.gisenv", flags="s"))
19+
tools = Tools(session=session)
1520

1621
# simple test: just scan the LAZ file
17-
gs.run_command(
18-
"r.in.pdal",
22+
tools.g_region(n=853535.43, w=635619.85, e=638982.55, s=848899.7)
23+
tools.r_in_pdal(
1924
input="/tmp/simple.laz",
2025
output="count_1",
2126
method="n",

0 commit comments

Comments
 (0)