红联Linux门户
Linux帮助

ubuntu安装QGIS

发布时间:2016-07-16 10:21:21来源:blog.csdn.net/u014124220/作者:xbotao2014
QGIS项目简介
QGIS是一个用户界面友好的桌面地理信息系统,可运行在Linux、Unix、Mac OSX和Windows等平台之上。QGIS是基于Qt,使用C++开发的一个用户界面友好、跨平台的开源版桌面地理信息系统。
QGIS项目开始于2002年 5月,是基于跨平台的图形工具Qt软件包,采用C++ 语言开发的一个GIS软件。目前的开发非常活跃,当前(2014年)的最新版本是QGIS 2.4 版。QGIS源码采用 GNU General Public License协议对外发布。
QGIS项目主页:http://www.qgis.org/en/site/
ubuntu安装QGIS
QGIS源码安装:http://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/INSTALL.html
 
配置环境
系统环境:ubuntu14.04 32bit
软件版本:QGIS2.8
 
指令安装
安装qgis可以通过添加安装源的形式进行
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install qgis
 
卸载qgis可以通过
apt-get remove qgis
apt-get purge qgis
 
源码安装
依赖环境
编译工具:
CMake >= 2.8.6
Flex >= 2.5.6
Bison >= 2.4
相关依赖环境:
Qt >= 4.8.0
Proj >= 4.4.x
GEOS >= 3.4
Sqlite3 >= 3.0.0
GDAL/OGR >= 1.4.x
Qwt >= 5.0 & (< 6.1 with internal QwtPolar)
expat >= 1.95
QScintilla2
根据自己的内核版本选择相应的指令安装,通过lsb_release -a指令查看内核版本
itman@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 14.04.1 LTS
Release:14.04
Codename:   trusty
在安装依赖项是可能会出现安装不成功的情况,可以切换安装镜像,重试的方法,重新尝试安装
 
wheezy
apt-get install bison cmake doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal1-dev libgeos-dev libgsl0-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqtwebkit-dev libqwt-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools python python-dev python-gdal python-mock python-nose2 python-psycopg2 python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
jessie
apt-get install bison cmake dh-python doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl0-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqtwebkit-dev libqwt-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools pyqt4.qsci-dev python-all python-all-dev python-gdal python-mock python-nose2 python-psycopg2 python-pyspatialite python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
stretch
apt-get install bison cmake dh-python doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqwt-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools pyqt4.qsci-dev python-all python-all-dev python-future python-gdal python-mock python-nose2 python-psycopg2 python-pyspatialite python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
precise
apt-get install bison cmake doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl0-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqtwebkit-dev libqwt5-qt4-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools python python-gdal python-mock python-psycopg2 python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
trusty
apt-get install bison cmake dh-python doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl0-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqtwebkit-dev libqwt5-qt4-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools python-all python-all-dev python-gdal python-mock python-nose2 python-psycopg2 python-pyspatialite python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
wily
apt-get install bison cmake cmake dh-python doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl0-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqtwebkit-dev libqwt5-qt4-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools pyqt4.qsci-dev python-all python-all-dev python-future python-gdal python-mock python-nose2 python-psycopg2 python-pyspatialite python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
xenial
apt-get install bison cmake dh-python doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqwt5-qt4-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools pyqt4.qsci-dev python-all python-all-dev python-future python-gdal python-mock python-nose2 python-psycopg2 python-pyspatialite python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
sid
apt-get install bison cmake dh-python doxygen flex gdal-bin git graphviz grass-dev libexpat1-dev libfcgi-dev libgdal-dev libgeos-dev libgsl-dev libopenscenegraph-dev libosgearth-dev libpq-dev libproj-dev libqca2-dev libqca2-plugin-ossl libqjson-dev libqscintilla2-dev libqt4-dev libqt4-opengl-dev libqt4-sql-sqlite libqwt5-qt4-dev libspatialindex-dev libspatialite-dev libsqlite3-dev lighttpd locales pkg-config poppler-utils pyqt4-dev-tools pyqt4.qsci-dev python-all python-all-dev python-future python-gdal python-mock python-nose2 python-psycopg2 python-pyspatialite python-qscintilla2 python-qt4 python-qt4-dev python-qt4-sql python-sip python-sip-dev python-yaml qt4-dev-tools qt4-doc-html spawn-fcgi txt2tags xauth xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xvfb cmake-curses-gui
 
安装编译环境
开始之前,先选择一个速度较快的安装源,然后按照下面步骤进行操作
首先安装gcc和g++编译器环境,同时安装ccache
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install ccache
创建链接到/usr/local/bin目录
cd /usr/local/bin
sudo ln -s /usr/bin/ccache gcc
sudo ln -s /usr/bin/ccache g++
 
使用git获取源码
首先创建源码存放目录
mkdir -p ${HOME}/dev/cpp
cd ${HOME}/dev/cpp
按照需求同步源码
Anonymous Checkout
cd ${HOME}/dev/cpp
git clone git://github.com/qgis/QGIS.git
Developer Checkout
cd ${HOME}/dev/cpp
git clone git@github.com:qgis/QGIS.git
如果不能使用git指令,使用sudo apt-get install git安装git工具
 
编译源码
cd QGIS
mkdir build-master
cd build-master
ccmake ..
执行ccmake ..以后会出现配置界面,配置相关的编译参数和一些依赖项目录。
进入配置界面以后,按c键检查配置信息,配置错误信息可以参考文章底部的 QAQ
在配置界面按 ‘c’ 检查配置,并根据提示错误修改相关系统配置,直到不提示错误为止,此时按下键盘上的 ‘g’ 生成makefile以及相关内容
下面是一些参数配置说明
CMAKE_INSTALL_PREFIX 编译完成后的软件安装目录,如果不想安装到默认/usr/bin目录下,可以创建自己目录mkdir -p ${HOME}/apps,并设置该项属性为${HOME}/apps
CMAKE_BUILD_TYPE 如果想要编译完成后的代码输出调试信息,可以设置为Debug,不过博主设置为Debug以后在代码编译到10%左右的时候报错
编译并生成可执行程序
make   // or make -j8
sudo make install
注: make时可使用多核同时处理,相关指令类似 make -j8,其中数字为计算机处理器核数。
 
QAQ
1.提示GDAL版本太低
CMake Warning at cmake/FindGDAL.cmake:114 (MESSAGE):
GDAL version is too old (1.10.1) to support GeoPackage. 1.11.0 or higher
is recommended.
Call Stack (most recent call first):
CMakeLists.txt:199 (FIND_PACKAGE)
解决方法:
手动安装高版本gdal, url: http://download.osgeo.org/gdal/
此处选择的为1.11.0版本gdal-1.11.0.tar.gz,程序安装完成以后,在目录/usr/local/bin中
cd ~/Downloads/
tar -zxvf gdal-1.11.0.tar.gz
cd cd gdal-1.11.0/
./configure
make
sudo make install
如果make时太慢,可以使用make -j8数字根据计算机处理器核数量进行调整
 
2.找不到qwtpolar目录
错误提示
CMake Error: The following variables are used in this project, but they are
set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake
files:
QWTPOLAR_INCLUDE_DIR
used as include directory in directory /home/itman/dev/cpp/QGIS/src/app
used as include directory in directory /home/itman/dev/cpp/QGIS/src/app
QWTPOLAR_LIBRARY
linked by target “qgis_app” in directory /home/itman/dev/cpp/QGIS/src/app
linked by target “qgis_apppythontest” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_attributetabletest” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_fieldcalculatortest” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_maptoolidentifyaction” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_maptoolselect” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_measuretool” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_qgisappclipboard” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
linked by target “qgis_vectorlayersaveasdialogtest” in directory
/home/itman/dev/cpp/QGIS/tests/src/app
解决方法:
手动安装qwt安装包,版本为6.0.2,URL:https://sourceforge.net/projects/qwt/files/
手动安装qwtpolar安装包,版本为1.0.1,URL:https://sourceforge.net/projects/qwtpolar/files/
下载完成以后,解压并安装,安装以后的目录在/usr/local下面
qmake 
make
sudo make install
并修改相关配置如下
QWTPOLAR_INCLUDE_DIR /usr/local/qwtpolar-1.0.0/include
QWTPOLAR_LIBRARY /usr/local/qwtpolar-1.0.0/lib/libqwtpolar.so 
QWT_INCLUDE_DIR  /usr/local/qwt-6.0.2/include 
QWT_LIBRARY  /usr/local/qwt-6.0.2/lib/libqwt.so 
 
3.pyuic-wrapper.sh: Permission denied
在编译到94%左右会提示错误,错误信息如下
[ 94%] Generating ui_widgetMerge.py
/bin/sh: 1: ../../../../../scripts/pyuic-wrapper.sh: Permission denied
make[2]: * [python/plugins/GdalTools/tools/ui_widgetMerge.py] Error 126
解决方法:
修改文件权限为777
chmod 777 pyuic-wrapper.sh
 
本文永久更新地址:http://www.linuxdiyf.com/linux/22417.html