[GRASS-dev] [GRASS GIS] #2873: Simplify usage of GRASS in Python from outside
GRASS GIS
trac at osgeo.org
Sun Jan 24 19:38:17 PST 2016
#2873: Simplify usage of GRASS in Python from outside
-------------------------+-------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: | Status: new
enhancement |
Priority: major | Milestone: 7.1.0
Component: Python | Version: svn-trunk
Resolution: | Keywords: startup, installation, scripts,
| interpreter, windows installer, pygrass,
CPU: | temporal, bootstrap, boilerplate
Unspecified | Platform: All
-------------------------+-------------------------------------------------
Comment (by wenzeslaus):
Replying to [comment:4 wenzeslaus]:
> ...it might be nicer to have one import instead two.
On the other hand, separating the stuff into its own module might have
some advantages. The API could look like:
{{{
#!python
import grass.script as gscript
import grass.session as gsession
session = gsession.create_session("~/grassdata", "nc_spm", "user1")
gscript.run_command(...)
session.close()
}}}
And in future perhaps allow:
{{{
#!python
session_a = gsession.create_session("~/grassdata", "nc_spm", "user1")
session_b = gsession.create_session("~/grassdata", "nc_spf", "PERMANENT")
session_a.run_command(...)
session_b.run_command(...)
session_b.close()
session_a.close()
}}}
Now uploading a third prototype which is in the separate package, you can
do something like:
{{{
#!python
session = gsession.init_data(location="test_xy", mapset="test1",
geostring='XY')
# ...
session.close()
}}}
Code is still messy and naming is not final but should work. Some
documentation provided. Please test.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2873#comment:5>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list