[GRASS-user] New CLI option --tmp-location in 7.5 to enhance --exec

Vaclav Petras wenzeslaus at gmail.com
Sat Aug 18 19:24:55 PDT 2018


On Thu, Aug 16, 2018 at 4:06 AM, Pierre Roudier <pierre.roudier at gmail.com>
wrote:
>
> Thanks Vaclav,


You are welcome. I hope it will be helpful.


> Looks like a great enhancement. It should make it easy to wrap it into
> a R package for example.


Yes, the idea for this is that it also should make easy to wrap GRASS GIS
in whatever you want.


> One question -- is that possible to refer to the input dataset in the
> script called
> by --exec? Something like:
>
> grass --tmp-location ~/data/elevation.tiff --exec "r.param.scale
> in=myinput out=myoutput param=slope size=9"


This makes sense since the GUI Startup (and/or Location Wizard) have this
functionality (also importing the file after using its SRS). However, this
is effectively an API and needs more considerations. How would you suggest
to deal with the output when `--tmp-location ~/data/elevation.tiff` creates
location with `elevation` raster but than myoutput is deleted with the rest
of the location? What about multiple inputs?

At this point, I'm hoping we can move forward through individual issues and
use cases (rather than revamping CLI altogether), so you remarks fall into
that well. Please, feel to submit an enhancement ticket ideally with a use
case, so we can discuss it there.

Please see also a little write-up I did for GSoC idea some time ago:

https://trac.osgeo.org/grass/wiki/GSoC/2018#Neweasy-to-useCLIandAPIforGRASSGIS

Best,
Vaclav

> Cheers,
>
> P
>
> On 15 August 2018 at 15:20, Vaclav Petras <wenzeslaus at gmail.com> wrote:
> > Dear user list,
> >
> > The (main) GRASS GIS executable, usually available as simply `grass` on
most
> > systems has now a new option (flag/parameter) in trunk (aka 7.5). The
option
> > is called --tmp-location.
> >
> > When specified, GRASS GIS automatically creates an new (and empty)
location
> > based on provided EPSG code or georeferenced file (similarly to what -c
flag
> > does). Newly it is also possible to provide string "XY" instead of EPSG
to
> > create XY (non-georeferenced) location.
> >
> > This temporary location has only PERMANENT mapset and the whole
location is
> > removed. The location is created in a temporary directory (which is also
> > deleted at the end).
> >
> > The flag --tmp-location is meant to be used together with --exec and it
is a
> > part of a lager endeavor to make the CLI easier for use from outside of
the
> > GRASS GIS session.
> >
> > If you are interested, please, test this new functionality. It is an
> > opportunity to provide feedback before this feature lands in the 7.6
> > release.
> >
> > Here are some things to try:
> >
> > * Execute a module in a location created based on EPSG:
> >
> >   grass --tmp-location EPSG:3358 --exec g.region -p
> >
> > * Execute Python script in a location created based on EPSG:
> >
> >   grass --tmp-location EPSG:3358 --exec script.py
> >
> > * Examine the created location using a Bash command:
> >
> >   grass --tmp-location EPSG:3358 --exec bash -c "g.proj -p && g.region
-p &&
> > g.mapset -p && g.gisenv GISDBASE,LOCATION_NAME sep=/"
> >
> > * Get SRS/CRS for a file:
> >
> >   grass --tmp-location ~/data/elevation.tiff --exec g.proj -p
> >
> > * Get help text for a module:
> >
> >   grass --tmp-location XY --exec r.neighbors --help
> >
> > See the documentation and `grass --help` for more hints (and let me
know how
> > these can be enhanced).
> >
> > Best regards,
> > Vaclav
> >
> >
> > https://trac.osgeo.org/grass/ticket/3537
> > https://trac.osgeo.org/grass/ticket/3585
> > https://trac.osgeo.org/grass/ticket/3586
> > https://trac.osgeo.org/grass/changeset/72790
> > https://trac.osgeo.org/grass/changeset/73096
> > https://trac.osgeo.org/grass/changeset/73098
> > https://trac.osgeo.org/grass/changeset/73099
> >
> >
> >
> > _______________________________________________
> > grass-user mailing list
> > grass-user at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/grass-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180818/e22c4cc8/attachment.html>


More information about the grass-user mailing list