Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
619 lines (503 sloc) 18.7 KB

Introduction to ace - actinia command execution

The ace tool allows the execution of a single GRASS GIS command or a list of GRASS GIS commands on an actinia REST service ( In addition it provides job management, the ability to list locations, mapsets and map layer the user has access to as well as the creation and deletion of mapsets.

The ace tool must be executed in an active GRASS GIS session and will use the current location of this session to access the actinia service.

The current location setting can be overridden by the --location LOCATION_NAME option. All commands will be executed per default in an ephemeral database. Hence, generated output must be exported using augmented GRASS commands.

The option --persistent MAPSET_NAME allows the execution of commands in the persistent user database. It can be used with --location LOCATION_NAMEoption.

Requirements and setup

Needed Python libraries

In case not yet present on the system, the following Python libraries are needed:

  • Linux: pip3 install click requests simplejson
  • Windows users (OSGeo4W, Advanced installation, search window):
    • three Python packages: python3-click, python3-requests, python3-simplejson

Installation of ace tools

To be run in a GRASS GIS session:

# importer installation
g.extension url= extension=importer

# exporter installation
g.extension url= extension=exporter 

# ace installation (g.extension support forthcoming)
mkdir -p $HOME/bin/
cd $HOME/bin/
chmod a+x ace

Authentication settings

The user must setup the following environmental variables to specify the actinia server and credentials:

# set credentials and REST server URL
export ACTINIA_USER='demouser'
export ACTINIA_PASSWORD='gu3st!pa55w0rd'
export ACTINIA_URL=''

Notes on the usage of external data sources

GRASS GIS commands can be augmented with actinia specific extensions. The + operator can be specified for an input parameter to import a web located resource and to specify the export of an output parameter.

See Example 1 and other examples below.

Available data

Importantly, the name of the local location and mapset must correspond to that on the actinia REST server.

Currently available datasets are (organized by projections):

Note that only selected datasets are available to the demo user (access is managed on a per-user base).

List locations, mapsets and maps

In order to list the locations the user has access to, run

ace --list-locations
['latlong_wgs84', 'nc_spm_08', 'ECAD']

The following command lists mapsets of current location in the active GRASS GIS session (nc_spm_08):

# running ace in the "nc_spm_08" location:
ace --location nc_spm_08 --list-mapsets
['PERMANENT', 'landsat', 'modis_lst']

All following commands can be executed in any active GRASS GIS location, since the location name at the actinia server is explicitly provided. In case the location option is not provided, the active location will be used. The following command lists mapsets of the provided location latlong_wgs84:

ace --location latlong_wgs84 --list-mapsets

but only if the actinia user is enabled; otherwise the following message appears:

ace --location latlong_wgs84 --list-mapsets
{'message': "{'Status': 'error', 'Messages': 'Unauthorized access to location "

To list all raster maps available in the specified mapset belonging to the provided location nc_spm_08, run:

ace --location nc_spm_08 --list-raster PERMANENT

To list all vector maps available in the specified mapset belonging to the current or a provided location, run:

ace --location nc_spm_08 --list-vector PERMANENT

List all raster maps in a location/mapset different from the current GRASS GIS session location:

ace --location ECAD --list-raster PERMANENT

Acessing maps in a different mapset

Simply use @name_of_mapset.

Job management

The ace tool can list jobs, choose from all, accepted, running, terminated, finished, error.

Show finished job(s) (note: the actual response may differ):

ace --list-jobs finished

resource_id-7a94b416-6f19-40c0-96c2-e62ce133ff89 finished 2018-12-17 11:33:58.965602
resource_id-87965ced-7242-43d2-b6da-5ded47b10702 finished 2018-12-18 08:45:29.959495
resource_id-b633740f-e0c5-4549-a663-9d58f9499531 finished 2018-12-18 08:52:36.669777
resource_id-0f9d6382-b8d2-4ff8-b41f-9b16e4d6bfe2 finished 2018-12-17 11:14:00.283710

Show running job(s), output only if anything is currently running:

ace --list-jobs running
resource_id-30fff8d6-5294-4f03-a2f9-fd7c857bf153 running 2018-12-18 21:58:04.107389

Show details about a specific job:

ace --info-job resource_id-b1cf32e3-bf07-4b57-858e-5d6a9767dd63
{'accept_datetime': '2019-09-03 00:50:11.725229',
 'accept_timestamp': 1567471811.7252264,
 'api_info': {'endpoint': 'rasterlayersresource',
              'method': 'GET',
              'path': '/api/v1/locations/nc_spm_08/mapsets/new_user_mapset/raster_layers',
              'request_url': ''},
 'datetime': '2019-09-03 00:50:11.813833',
 'http_code': 200,
 'message': 'Processing successfully finished',
 'process_chain_list': [{'1': {'inputs': {'mapset': 'new_user_mapset',
                                          'type': 'raster'},
                               'module': 'g.list'}}],
 'process_log': [{'executable': 'g.list',
                  'parameter': ['mapset=new_user_mapset', 'type=raster'],
                  'return_code': 0,
                  'run_time': 0.0502924919128418,
                  'stderr': [''],
                  'stdout': ''}],
 'process_results': [],
 'progress': {'num_of_steps': 1, 'step': 1},
 'resource_id': 'resource_id-b1cf32e3-bf07-4b57-858e-5d6a9767dd63',
 'status': 'finished',
 'time_delta': 0.08862900733947754,
 'timestamp': 1567471811.813823,
 'urls': {'resources': [],
          'status': ''},
 'user_id': 'demouser'}

Inspecting the REST call prior to submission: show process chain

To generate the actinia process chain JSON request simply add the --dry-run flag:

# example: compute slope from an elevation map
ace --dry-run --location nc_spm_08 r.slope.aspect elevation=elevation slope=myslope

which will deliver the output:

  "version": "1",
  "list": [
      "module": "r.slope.aspect",
      "id": "r.slope.aspect_1804289383",
      "inputs": [
          "param": "elevation",
          "value": "elevation"
          "param": "format",
          "value": "degrees"
          "param": "precision",
          "value": "FCELL"
          "param": "zscale",
          "value": "1.0"
          "param": "min_slope",
          "value": "0.0"
      "outputs": [
          "param": "slope",
          "value": "myslope"

Available export formats

At time (more to come) the following export formats are currently supported:

  • raster: GTiff
  • vector: ESRI_Shapefile, GeoJSON, GML
  • table: CSV, TXT

The vector formats will be extended in future versions of actina with Geopackage and SQLite formats.

Displaying a map - map rendering

It is very easy and fast to render a map (note: the "demouser" is not enabled):

# check amount of pixels, just FYI
ace --location latlong_wgs84 globcover@globcover
ace --location latlong_wgs84 --render-raster globcover@globcover

ESA Globcover map shown by actinia

Examples for ephemeral processing

Ephemeral processing is the default processing approach of actinia. Each single command or all commands in a shell script, will be executed in an ephemeral mapset. This mapset will be removed after processing. The output of GRASS GIS modules can be marked for export, to store the computational result for download and further analysis.

Command line examples

Running the module g.list in the location defined by the active GRASS GIS session in an ephemeral mapset, that has only the PERMANENT mapset in its search path:

ace --location nc_spm_08 g.list raster

Resource status accepted
Resource poll status: finished
Processing successfully finished
Resource status finished

{'resources': [],
 'status': ''}

Running the module g.region in a new ephemeral location, to show the default region of a temporary mapset:

ace --location nc_spm_08 g.region -p

Resource status accepted
Resource poll status: finished
Processing successfully finished
Resource status finished
projection: 99 (Lambert Conformal Conic)
zone:       0
datum:      nad83
ellipsoid:  a=6378137 es=0.006694380022900787
north:      320000
south:      10000
west:       120000
east:       935000
nsres:      500
ewres:      500
rows:       620
cols:       1630
cells:      1010600

{'resources': [],
 'status': ''}

Script examples

Example 1: computing slope and aspect and univariate statistics from an elevation model

The following commands (to be stored in a script and executed with ace) will import a raster layer from an internet source as raster map elev, sets the computational region to the map and computes the slope. Additional information about the raster layer are requested with

Store the following script as text file

# grass78 ~/grassdata/nc_spm_08/user1/
# Import the web resource `elev_ned_30m.tif` and set the region to the imported map
g.region raster=elev@ -ap
# Compute univariate statistics
r.univar map=elev elev
# Compute the slope of the imported map and mark it for export as geotiff file
r.slope.aspect elevation=elev slope=slope_elev+GTiff slope_elev

Save the script in a text file, e.g. /tmp/

Just for inspection, to generate the actinia process chain JSON request add the --dry-run flag:

ace --dry-run --location nc_spm_08 --script /tmp/

The output should look like this:

  "version": "1",
  "list": [
      "module": "g.region",
      "id": "g.region_1804289383",
      "flags": "pa",
      "inputs": [
          "import_descr": {
            "source": "",
            "type": "raster"
          "param": "raster", "value": "elev"
      "module": "r.univar",
      "id": "r.univar_1804289383",
      "inputs": [
        {"param": "map", "value": "elev"},
        {"param": "percentile", "value": "90"},
        {"param": "separator", "value": "pipe"}
      "module": "",
      "id": "r.info_1804289383",
      "inputs": [{"param": "map", "value": "elev"}]
      "module": "r.slope.aspect",
      "id": "r.slope.aspect_1804289383",
      "inputs": [
        {"param": "elevation", "value": "elev"},
        {"param": "format", "value": "degrees"},
        {"param": "precision", "value": "FCELL"},
        {"param": "zscale", "value": "1.0"},
        {"param": "min_slope", "value": "0.0"}
      "outputs": [
          "export": {"format": "GTiff", "type": "raster"},
          "param": "slope", "value": "slope_elev"
      "module": "",
      "id": "r.info_1804289383",
      "inputs": [{"param": "map", "value": "slope_elev"}]

To eventually execute the saved script on the actinia server (it will internally convert the script to JSON and send this as a payload to the server), run:

ace --location nc_spm_08 --script /tmp/

The resulting data are provided as REST resources for download.

Example 2: Orthophoto image segmentation with export

Store the following script as text file /tmp/

# grass78 ~/grassdata/nc_spm_08/user1/
# Import the web resource and set the region to the imported map
# we apply a trick for the import of multi-band GeoTIFFs:
# install with: g.extension importer
importer raster=ortho2010@
# The importer has created three new raster maps, one for each band in the geotiff file
# stored them in an image group map=ortho2010.1 map=ortho2010.2 map=ortho2010.3
# Set the region and resolution
g.region raster=ortho2010.1 res=1 -p
# Note: the RGB bands are organized as a group
i.segment group=ortho2010 threshold=0.25 output=ortho2010_segment_25+GTiff goodness=ortho2010_seg_25_fit+GTiff
# Finally vectorize segments with and export as a GeoJSON file input=ortho2010_segment_25 type=area output=ortho2010_segment_25+GeoJSON

Run the script saved in a text file as

ace --location nc_spm_08 --script /tmp/

The results are provided as REST resources.

Examples for persistent processing

GRASS GIS commands can be executed in a user specific persistent database. The user must create a mapset in an existing location. This mapsets can be accessed via ace. All processing results of commands run in this mapset, will be stored persistently. Be aware that the processing will be performed in an ephemeral database that will be moved to the persistent storage using the correct name after processing.

To create a new mapset in the nc_spm_08 location with the name test_mapset the following command must be executed (note: the "demouser" is not enabled for this):

ace --location nc_spm_08 --create-mapset test_mapset

Run the commands from the statistic script in the new persistent mapset

ace --location nc_spm_08 --persistent test_mapset --script /path/to/

Show all raster maps that have been created with the script in test_mapset

ace --location nc_spm_08 --persistent test_mapset g.list type=raster mapset=test_mapset

Show information about raster map elev and slope_elev

ace --location nc_spm_08 --persistent test_mapset elev@test_mapset
ace --location nc_spm_08 --persistent test_mapset slope_elev@test_mapset

Delete the test_mapset

ace --location nc_spm_08 --delete-mapset test_mapset

If the active GRASS GIS session has identical location/mapset settings, then an alias can be used to avoid the persistent option in each single command call:

alias acp="ace --persistent `g.mapset -p`"

We assume that in the active GRASS GIS session the current location is nc_spm_08 and the current mapset is test_mapset. Then the commands from above can be executed in the following way:

ace --create-mapset test_mapset
acp --location nc_spm_08 --script /path/to/
acp --location nc_spm_08 g.list type=raster mapset=test_mapset
acp --location nc_spm_08 elev@test_mapset
acp --location nc_spm_08 slope_elev@test_mapset

Super admin tasks

(note: the "demouser" is not enabled for this)

Creation of new locations

# create new location
ace --create-location mylatlon 4326
# create new mapset within location
ace --location mylatlon --create-mapset user1

Installing of GRASS GIS addons (extensions)

# list existing addons, see also
ace --location latlong_wgs84 g.extension -l

# install machine learning addon
ace --location latlong_wgs84 g.extension
You can’t perform that action at this time.