当前位置: 首页 > 工具软件 > GRASS > 使用案例 >

Ubuntu 18.04 安装GRASS GIS 7.8.3

梅飞宇
2023-12-01

在之前的 Ubuntu 16.04 安装 Grass gis 7.6.1 中主要是通过添加ppa源的方法安装预编译包,但由于众所周知的原因可能会失败,所以最好的安装方法是下载源码后自己编译安装,下面是安装步骤:

  • 安装依赖项(PROJ、GEOS、GDAL库)和编译工具

  • (注意:对于GRASS 7.8+需要Python 3!)

直接在终端中运行以下命令:

# 首先更新apt源
sudo apt-get update && sudo apt-get upgrade -y

# 安装 PROJ
sudo apt-get install libproj-dev proj-data proj-bin -y

# 安装 GEOS
sudo apt-get install libgeos-dev -y

# 安装 GDAL
sudo apt-get install libgdal-dev python3-gdal gdal-bin -y

# 安装 PDAL 
sudo apt-get install libpdal-dev pdal libpdal-plugin-python -y

# 将python版本切换为3.6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1

# 安装编译器和其他依赖项
# 这是一条单独的命令,请将它完全复制粘贴到终端:
sudo apt-get install \
  build-essential \
  flex make bison gcc libgcc1 g++ ccache \
  python3 python3-dev \
  python3-opengl \
  python-wxversion python-wxtools python-wxgtk3.0 python3-wxgtk4.0 \
  python3-dateutil libgsl-dev python3-numpy \
  wx3.0-headers wx-common libwxgtk3.0-dev \
  libwxbase3.0-dev   \
  libncurses5-dev \
  libbz2-dev \
  zlib1g-dev gettext \
  libtiff5-dev libpnglite-dev \
  libcairo2 libcairo2-dev \
  sqlite3 libsqlite3-dev \
  libpq-dev \
  libreadline6-dev libfreetype6-dev \
  libfftw3-3 libfftw3-dev \
  libboost-thread-dev libboost-program-options-dev liblas-c-dev \
  subversion libzstd-dev \
  checkinstall \
  libglu1-mesa-dev libxmu-dev \
  ghostscript wget -y

用于NVIZ视频输出的视频编解码器库:(可选)

sudo apt-get install \
  libav-tools libavutil-dev ffmpeg2theora \
  libffmpegthumbnailer-dev \
  libavcodec-dev \
  libxmu-dev \
  libavformat-dev libswscale-dev
  • GRASS GIS7.8.3源码下载

获取源代码有两种方法:

  1. 每周快照(不能更新,不推荐)
# 下载最新的GRASS GIS 7.x稳定发布源代码:
mkdir $HOME/src/
cd  $HOME/src/
wget https://grass.osgeo.org/grass78/source/snapshot/grass-7.8.git_src_snapshot_latest.tar.gz

# 解压源代码包,然后删除压缩包
tar xvfz grass-7.8.git_src_snapshot_latest.tar.gz
rm -f grass-7.8.git_src_snapshot_latest.tar.gz 

# 重命名源代码目录
mv grass-7.8.git_src_snapshot_20??_??_?? grass-7.8.latest

2. 来自GitHub存储库的源代码(可以在将来轻松更新本地副本)

git clone https://github.com/OSGeo/grass.git grass-7.8.latest.git
cd grass-7.8.latest.git/
git checkout releasebranch_7_8 #切换到7.8分支

也可以直接从云盘下载:链接:https://pan.baidu.com/s/10mYXgn2xt6RhMa7kQX5B7A 提取码:h19p

  • GRASS GIS7.8.3源码下载

现在可以编译源代码来生成GRASS GIS二进制文件,在终端中运行:

# "configure" source code for local machine (checks for CPU type etc):
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'
#MYCXXFLAGS=''
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'

LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure \
  --with-cxx \
  --enable-largefile \
  --with-proj --with-proj-share=/usr/share/proj \
  --with-gdal=/usr/bin/gdal-config \
  --with-python \
  --with-geos \
  --with-sqlite \
  --with-nls \
  --with-zstd \
  --with-liblas \
  --with-pdal \
  --with-cairo --with-cairo-ldflags=-lfontconfig \
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
  --with-wxwidgets \
  --with-fftw \
  --with-motif \
  --with-opengl-libs=/usr/include/GL \
  --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
  --without-netcdf \
  --without-mysql \
  --without-odbc \
  --without-openmp \
  --without-ffmpeg
  • GRASS GIS7.8.3 源码编译

编译源代码(从源代码生成二进制代码),在命令行中运行:

# j4 表示调用cpu的4核
make -j4

将生成的GRASS GIS二进制文件安装到/usr/local/:

sudo make install

最后,清除编译文件:

make distclean

至此,安装完成,在终端中运行:

grass78

参考资料: Compile and Install Ubuntu

 类似资料: