我想在amazon机器上运行grass78,使用centOS,而不是GUI。由于很大的困难,我得以安装GRASS78 (https://grass.osgeo.org/download/的最新稳定版本)。
当我运行以下命令时(在将GRASS_GUI env设置为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还是使用这个(https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library)?
另外,我不确定在启动草之前需要设置哪些环境变量。我设定了GRASSBIN,GISBASE,GISDBASE。但我不确定MAPSET和LOCATION环境变量的值。
而且,每次我用
from grass.script import gcore
我得到的错误是没有找到名为grass的模块。
因为我使用的是centOS,所以我不能做任何类似sudo apt install grass-core的事情。当我这么做的时候,sudo yum install grass,出于某种原因,它安装了gov6.4.4版本。
我还尝试使用grass_session (pip install grass_session)在grass会话中运行代码,但不走运的是,二进制文件(即/usr/local/bin/草原78)本身表明没有名为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.tifStarting 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文件的信息,请告诉我。
发布于 2022-01-17 16:22:24
这可能已经很晚了,但我发现这个问题也有同样的问题。我发现导入顺序不同:grass_session必须在其他grass模块之前导入,例如:
from grass_session import Session
import grass.script as gscript
from grass.pygrass.vector import VectorTopohttps://stackoverflow.com/questions/68358076
复制相似问题