Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI: Add support for grass.pygrass API to Graphical Modeler #3369

Merged
merged 16 commits into from
Jan 24, 2024

Conversation

landam
Copy link
Member

@landam landam commented Jan 21, 2024

Currently the Graphical Modeler is using GRASS script API (grass.script.core.run_command()) when converting model into Python code. This cannot be changed by the user.

This PR adds support for PyGRASS API (grass.pygrass.modules.Module). GRASS script package is still default. This can be changed in the settings.

image

Compare sample model:

  1. GRASS script package (default):
from grass.script import run_command
...
    run_command("v.rast.stats",
                flags='c',
                map="zipcodes_wake",
                layer="1",
                type="point,line,boundary,centroid,area",
                raster="elevation",
                column_prefix="rst",
                method="average",
                percentile=90)
...
  1. and PyGRASS:
from grass.pygrass.modules import Module
...
    Module("v.rast.stats",
           flags='c',
           map="zipcodes_wake",
           layer="1",
           type=['point', 'line', 'boundary', 'centroid', 'area'],
           raster="elevation",
           column_prefix="rst",
           method="average",
           percentile=90)
...

@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python HTML Related code is in HTML docs labels Jan 21, 2024
@landam landam self-assigned this Jan 21, 2024
@landam landam added this to the 8.4.0 milestone Jan 21, 2024
@landam landam marked this pull request as draft January 21, 2024 22:30
@landam landam marked this pull request as ready for review January 21, 2024 22:52
@landam landam requested a review from pesekon2 January 21, 2024 22:52
@pesekon2
Copy link
Contributor

It looks very nice, thanks. I found only one little stain on this otherwise magnificent piece of art. When you have an output that is not intermediate and it thus generates v.out.ogr/r.out.gdal command in the PyWPS export, the indentation in the Module command does not look so nice.

        Module("v.out.ogr",
                    input="region",
                    output=os.path.join(
                        tempfile.gettempdir(),
                        "region" + ".gml"),
                    format="GML")

@landam
Copy link
Member Author

landam commented Jan 23, 2024

It looks very nice, thanks. I found only one little stain on this otherwise magnificent piece of art. When you have an output that is not intermediate and it thus generates v.out.ogr/r.out.gdal command in the PyWPS export, the indentation in the Module command does not look so nice.

        Module("v.out.ogr",
                    input="region",
                    output=os.path.join(
                        tempfile.gettempdir(),
                        "region" + ".gml"),
                    format="GML")

Fix in 25f007f. Now:

        Module("v.out.ogr",
               input="jena_boundary_5km",
               output=os.path.join(
                       tempfile.gettempdir(),
                       "jena_boundary_5km" + ".gml"),
               format="GML")

@landam landam merged commit 0ad33cc into OSGeo:main Jan 24, 2024
23 checks passed
@landam landam deleted the gmodeler-pygrass branch January 24, 2024 19:51
@wenzeslaus wenzeslaus changed the title Graphical Modeler: add support for PyGRASS API wxGUI: Add support for grass.pygrass API to Graphical Modeler Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs GUI wxGUI related HTML Related code is in HTML Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants