0

I want to run grass78 on an amazon-linux machine, with centOS, no GUI. By great difficulty, I was able to install GRASS78 (the latest stable release from https://grass.osgeo.org/download/).

When I run the below command (after setting GRASS_GUI env var as text)

(.venv) [ec2-user@ip-10-0-3-14 volume_calc]$ grass78
Starting GRASS GIS...
ERROR: Path '/home/ec2-user/volume_calc/<UNKNOWN>/<UNKNOWN>' doesn't exist
Exiting...

I think, with this, I can be sure that grass is installed.

But please tell me is there proper documentation to install it. I tried this (https://copr.fedorainfracloud.org/coprs/neteler/grass78/) but it fails because there is an epel file missing there for centos7.

Now, I want to run a python script that will give me the volume of the polygon object that I am passing to the script. I am not sure, which way to run the GRASS. Do I have to start Grass explicitly or use this (https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library)?

Also, I am not sure which environment variables need to be set before starting the GRASS. I have set GRASSBIN, GISBASE, GISDBASE. But I am not sure about the values of the MAPSET and LOCATION environment variables.

And, every time I use

from grass.script import gcore

I get the error that no module named grass was found.

Since I am using centOS, I cannot do anything like sudo apt install grass-core. And when I did, sudo yum install grass, it installed version grass6.4.4 for some reason.

I also tried using grass_session (pip install grass_session) to run the code in the GRASS session, but with no luck, the binary file (i.e. /usr/local/bin/grass78) itself says that no module named grass.

I am running the below command on the terminal.

grass78 -c EPSG:4326 location --exec python3 /home/ec2-user/volume_calc/grass_calc_vol.py area_file=/home/ec2-user/volume_calc/media/tour_id/temp-testing/area_file.geojson  points_file=/home/ec2-user/volume_calc/media/tour_id/temp-testing/points_file.geojson  dsm_file=/home/ec2-user/volume_calc/media/tour_id/files/dsm-volume.tif
Starting GRASS GIS...
Creating new GRASS GIS location <location>...
Traceback (most recent call last):
  File "/usr/local/bin/grass78", line 2349, in <module>
    main()
  File "/usr/local/bin/grass78", line 2249, in main
    geofile=params.geofile, create_new=True)
  File "/usr/local/bin/grass78", line 1003, in set_mapset
    create_location(gisdbase, location_name, geofile)
  File "/usr/local/bin/grass78", line 794, in create_location
    from grass.script import core as gcore  # pylint: disable=E0611
ModuleNotFoundError: No module named 'grass'

Let me know if you need more information about the grass_calc_vol file.

Ayush Chauhan
  • 37
  • 1
  • 7
  • `grass` is available with pip https://pypi.org/project/grass/ – Knud Larsen Jul 13 '21 at 07:35
  • @KnudLarsen the grass that you are referring to is GRASS (Graph Regularized Annotation via Semi-Supervised learning) is a tool for annotating de novo transcriptome assemblies using data from closely related species with previously annotated genomes. I don't need that GRASS. – Ayush Chauhan Jul 13 '21 at 08:42
  • Sorry, I didn't read the pypi text ..... – Knud Larsen Jul 13 '21 at 11:01

1 Answers1

2

This may be very late, but I just found this question having had the same problem. I found the order of imports made the difference: grass_session must be imported before other grass modules, e.g:

from grass_session import Session
import grass.script as gscript
from grass.pygrass.vector import VectorTopo
sobmortin
  • 55
  • 9