0

我想在 amazon-linux 机器上运行 Grass78,使用 centOS,没有 GUI。非常困难,我能够安装 GRASS78(来自https://grass.osgeo.org/download/的最新稳定版本)。

当我运行以下命令时(将GRASS_GUIenv var 设置为之后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...

我认为,有了这个,我可以确定安装了草。

但请告诉我是否有适当的文档来安装它。我试过这个(https://copr.fedorainfracloud.org/coprs/neteler/grass78/)但它失败了,因为那里缺少一个用于centos7的epel文件。

现在,我想运行一个 python 脚本,它会给我传递给脚本的多边形对象的体积。我不确定,以哪种方式运行 GRASS。我是否必须明确启动 Grass 或使用它(https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library)?

另外,我不确定在启动 GRASS 之前需要设置哪些环境变量。我设置了GRASSBIN, GISBASE, GISDBASE. 但我不确定MAPSETLOCATION环境变量的值。

而且,每次我使用

from grass.script import gcore

我收到没有找到名为 Grass 的模块的错误。

因为我使用的是centOS,所以我不能做任何事情sudo apt install grass-core。当我这样做时sudo yum install grass,它出于某种原因安装了版本grass6.4.4。

我还尝试使用grass_session ( pip install grass_session) 在GRASS 会话中运行代码,但没有运气,二进制文件(即/usr/local/bin/grass78)本身表明没有名为grass 的模块。

我在终端上运行以下命令。

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'

如果您需要有关 Grass_calc_vol 文件的更多信息,请告诉我。

4

1 回答 1

0

这可能很晚了,但我刚刚发现这个问题有同样的问题。我发现导入的顺序有所不同:grass_session必须在其他草模块之前导入,例如:

from grass_session import Session
import grass.script as gscript
from grass.pygrass.vector import VectorTopo
于 2022-01-17T16:22:24.410 回答