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

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

Thanks Vaclav,

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

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"

Cheers,

P

On 15 August 2018 at 15:20, Vaclav Petras <wenzeslaus@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@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Dear Pierre,

Just in case you are not aware of it, GRASS and R integrate very nicely:
https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7

Cheers,
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Pierre Roudier
Sent: torsdag 16. august 2018 10:07
To: Vaclav Petras <wenzeslaus@gmail.com>
Cc: GRASS user list <grass-user@lists.osgeo.org>
Subject: Re: [GRASS-user] New CLI option --tmp-location in 7.5 to enhance --exec

Thanks Vaclav,

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

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"

Cheers,

P

On 15 August 2018 at 15:20, Vaclav Petras <wenzeslaus@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@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Thanks Stephan,

I'm aware of rgrass7 and spgrass6 -- I had in mind a package a lot
lighter, that basically "hides" the specificities of GRASS (eg the
notions of GRASSDATA, of locations, of mapsets...) from the user, and
just run a GRASS command on a GDAL/OGR type file.

Cheers,

P

On 16 August 2018 at 20:37, Stefan Blumentrath
<Stefan.Blumentrath@nina.no> wrote:

Dear Pierre,

Just in case you are not aware of it, GRASS and R integrate very nicely:
https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7

Cheers,
Stefan

-----Original Message-----
From: grass-user <grass-user-bounces@lists.osgeo.org> On Behalf Of Pierre Roudier
Sent: torsdag 16. august 2018 10:07
To: Vaclav Petras <wenzeslaus@gmail.com>
Cc: GRASS user list <grass-user@lists.osgeo.org>
Subject: Re: [GRASS-user] New CLI option --tmp-location in 7.5 to enhance --exec

Thanks Vaclav,

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

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"

Cheers,

P

On 15 August 2018 at 15:20, Vaclav Petras <wenzeslaus@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@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

* Vaclav Petras <wenzeslaus@gmail.com> [2018-08-14 23:20:16 -0400]:

..

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

Perhaps test if the file exists and, if not, exit with an informative error
message?

In Python:

import os.path
os.path.isfile(fname)

?

Currently, if the file does not exist, the process hangs:

Cleaning up temporary files...
Starting GRASS GIS...

* 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

All works.
Fantastic work!

Kudos Radek and Vaclav,
Nikos

On Thu, Aug 16, 2018 at 6:39 AM, Nikos Alexandris <nik@nikosalexandris.net> wrote:

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

Perhaps test if the file exists and, if not, exit with an informative error
message?

In Python:

import os.path
os.path.isfile(fname)

?

Hi Nikos,

sounds good to me. Do you want to submit an issue and suggest a patch?

Vashek

Currently, if the file does not exist, the process hangs:

Cleaning up temporary files...
Starting GRASS GIS...
  • 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

All works.
Fantastic work!

Kudos Radek and Vaclav,
Nikos

On Thu, Aug 16, 2018 at 4:06 AM, Pierre Roudier <pierre.roudier@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@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@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Vaclav Petras <wenzeslaus@gmail.com> [2018-08-14 23:20:16 -0400]:

* Get SRS/CRS for a file:

grass --tmp-location ~/data/elevation.tiff --exec g.proj -p

Nikos:

Perhaps test if the file exists and, if not, exit with an informative error
message?

In Python:

import os.path
os.path.isfile(fname)
?

Hi Nikos,

sounds good to me. Do you want to submit an issue and suggest a patch?

Vashek

https://trac.osgeo.org/grass/ticket/3537#comment:8

[rest deleted]

Nikos