QGIS: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 7: Line 7:
<!--T:2-->
<!--T:2-->
IMPORTANT
IMPORTANT
<!--T:3-->
<!--T:3-->
Never make intense use of QGIS on the login nodes! Submit jobs using the command line whenever possible and if you must visualize your data using the GUI, please do so on an interactive node. Using parallel rendering on the shared login nodes will result in the termination of your session.
Never make intense use of QGIS on the login nodes! Submit jobs using the command line whenever possible and if you must visualize your data using the GUI, please do so on an interactive node. Using parallel rendering on the shared login nodes will result in the termination of your session.


== Loading QGIS == <!--T:3-->
== Loading QGIS == <!--T:4-->
You will first need to load gcc
You will first need to load gcc
{{Command
{{Command
Line 16: Line 17:
}}  
}}  


<!--T:4-->
<!--T:5-->
Then, you will need to load the QGIS module; there could potentially be several versions available and you can see a list of all of them using the command  
Then, you will need to load the QGIS module; there could potentially be several versions available and you can see a list of all of them using the command  
{{Command
{{Command
Line 26: Line 27:
}}  
}}  


<!--T:5-->
<!--T:6-->
You might also have to load various other modules depending on the packages you need to install. For example, "rgdal" will require that you load a module called "gdal", which itself requires that you load nixpkgs and gcc. Nixpkgs should already be loaded by default. You can ensure that it is by running
You might also have to load various other modules depending on the packages you need to install. For example, "rgdal" will require that you load a module called "gdal", which itself requires that you load nixpkgs and gcc. Nixpkgs should already be loaded by default. You can ensure that it is by running


<!--T:6-->
<!--T:7-->
{{Command
{{Command
|module list
|module list
}}  
}}  


<!--T:7-->
<!--T:8-->
If nixpkgs is not listed, you can load it by running
If nixpkgs is not listed, you can load it by running


<!--T:8-->
<!--T:9-->
{{Command
{{Command
|module load nixpkgs/16.09
|module load nixpkgs/16.09
}}  
}}  


<!--T:9-->
<!--T:10-->
If any package fails to install, be sure to read the error message carefully, as it might give you some details concerning some additional modules you need to load. You can also find out if a module is dependent on any other module by running
If any package fails to install, be sure to read the error message carefully, as it might give you some details concerning some additional modules you need to load. You can also find out if a module is dependent on any other module by running
{{Command
{{Command
Line 49: Line 50:




====Command-line QGIS==== <!--T:31-->
====Command-line QGIS==== <!--T:11-->
You can execute QGIS by running a Python script:
You can execute QGIS by running a Python script:


<!--T:16-->
<!--T:12-->
{{Command|python qgis_code.py}}
{{Command|python qgis_code.py}}


<!--T:32-->
<!--T:13-->
1. Place your python code in a script file, in this case the [https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html file] is called ''qgis_code.py''.
1. Place your python code in a script file, in this case the [https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html file] is called ''qgis_code.py''.


<!--T:33-->
<!--T:14-->
{{File
{{File
from qgis.core import *
from qgis.core import *
Line 81: Line 82:
}}
}}


<!--T:34-->
<!--T:14-->
2. Copy the following content in a job submission script called ''job.sh'':
2. Copy the following content in a job submission script called ''job.sh'':


  <!--T:35-->
  <!--T:15-->
{{File
{{File
   |name=job.sh
   |name=job.sh
Line 100: Line 101:
}}
}}


<!--T:36-->
<!--T:16-->
3. Submit the job with:
3. Submit the job with:


  <!--T:37-->
  <!--T:17-->
<source lang="bash">
<source lang="bash">
sbatch job.sh
sbatch job.sh
</source>
</source>


<!--T:38-->
<!--T:18-->
For more on submitting jobs, see the [[Running jobs]] page.
For more on submitting jobs, see the [[Running jobs]] page.




==Using the GUI== <!--T:46-->
==Using the GUI== <!--T:19-->

Revision as of 19:16, 10 October 2018


QGIS is a free and open-source cross-platform desktop geographic information system (GIS) application that supports viewing, editing, and analysis of geospatial data.

IMPORTANT

Never make intense use of QGIS on the login nodes! Submit jobs using the command line whenever possible and if you must visualize your data using the GUI, please do so on an interactive node. Using parallel rendering on the shared login nodes will result in the termination of your session.

Loading QGIS[edit]

You will first need to load gcc

Question.png
[name@server ~]$ module load gcc/5.4.0

Then, you will need to load the QGIS module; there could potentially be several versions available and you can see a list of all of them using the command

Question.png
[name@server ~]$ module spider qgis

You can load a particular QGIS module using a command like

Question.png
[name@server ~]$ module load qgis/2.18.24

You might also have to load various other modules depending on the packages you need to install. For example, "rgdal" will require that you load a module called "gdal", which itself requires that you load nixpkgs and gcc. Nixpkgs should already be loaded by default. You can ensure that it is by running

Question.png
[name@server ~]$ module list

If nixpkgs is not listed, you can load it by running

Question.png
[name@server ~]$ module load nixpkgs/16.09

If any package fails to install, be sure to read the error message carefully, as it might give you some details concerning some additional modules you need to load. You can also find out if a module is dependent on any other module by running

Question.png
[name@server ~]$ module spider gdal/2.2.1


Command-line QGIS[edit]

You can execute QGIS by running a Python script:

Question.png
[name@server ~]$ python qgis_code.py

1. Place your python code in a script file, in this case the file is called qgis_code.py.

{{File from qgis.core import *

  1. supply path to qgis install location

QgsApplication.setPrefixPath("/path/to/qgis/installation", True)

  1. create a reference to the QgsApplication, setting the
  2. second argument to False disables the GUI

qgs = QgsApplication([], False)

  1. load providers

qgs.initQgis()

  1. Write your code here to load some layers, use processing
  2. algorithms, etc.
  1. When your script is complete, call exitQgis() to remove the
  2. provider and layer registries from memory

qgs.exitQgis() }}

2. Copy the following content in a job submission script called job.sh:


File : job.sh

#!/bin/bash
#SBATCH --account=def-someacct   # replace this with your own account
#SBATCH --ntasks=1               # number of MPI processes
#SBATCH --mem-per-cpu=2048M      # memory; default unit is megabytes
#SBATCH --time=0-00:15           # time (DD-HH:MM)
module load gcc
module load qgis

python qgis_code.py


3. Submit the job with:

sbatch job.sh

For more on submitting jobs, see the Running jobs page.


Using the GUI[edit]