Qgis

From KENET Training
Revision as of 19:07, 10 January 2026 by Atambo (talk | contribs) (Created page with "= QGIS (Remote Desktop) Tutorial - KENET HPC Cluster = == Overview == '''QGIS''' is a free and open-source Geographic Information System that enables users to create, edit, v...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

QGIS (Remote Desktop) Tutorial - KENET HPC Cluster

Overview

QGIS is a free and open-source Geographic Information System that enables users to create, edit, visualize, analyze, and publish geospatial information. Running on the KENET HPC cluster through Remote Desktop provides access to substantial computational resources for processing large spatial datasets, performing complex spatial analyses, and generating professional cartographic outputs.

Use Cases: QGIS is particularly valuable for map creation and cartographic design, spatial data analysis and geoprocessing, remote sensing and satellite imagery processing, environmental modeling and land use analysis, urban planning and infrastructure development, analyzing GPS and field survey data, creating interactive web maps and spatial databases, and teaching GIS concepts and spatial analysis methods.

Access: QGIS is available through Remote Desktop sessions on the KENET Open OnDemand web portal at https://ondemand.vlab.ac.ke

Code Examples: All code examples for this tutorial are available in our GitHub repository at https://github.com/Materials-Modelling-Group/training-examples


Prerequisites

Before using QGIS, you should have an active KENET HPC cluster account with access to the Open OnDemand portal. Basic understanding of geographic concepts like coordinates, projections, and spatial relationships will be helpful. Familiarity with different spatial data formats such as shapefiles, GeoJSON, and raster files is beneficial. Your spatial data should be stored in accessible directories on the cluster, preferably in standard GIS formats.


Launching QGIS

Step 1: Start Remote Desktop Session

Begin by logging into Open OnDemand at https://ondemand.vlab.ac.ke. Click the Interactive Apps menu and select Remote Desktop to launch a full desktop environment on a compute node.

File:OOD Desktop Menu.png
Navigate to Interactive Apps → Remote Desktop

Step 2: Configure Desktop Session

Configure the resources based on the size and complexity of your spatial datasets.

Parameter Description Recommended Value
Partition Queue for job execution normal for standard GIS work
Walltime Maximum runtime in hours 4-8 hours for interactive mapping, up to 24 for large processing
CPU Cores Number of processor cores 4-8 cores for raster processing
Memory RAM allocation 16-32 GB for large datasets, 64 GB for satellite imagery
File:OOD Desktop Form.png
Desktop session configuration

Tip: Large raster datasets like satellite imagery require substantial memory. Request adequate resources to avoid crashes during processing.

Step 3: Launch QGIS from Desktop

Once your remote desktop starts, launch QGIS by clicking Applications in the top menu, navigating to Graphics or Education, and selecting QGIS Desktop. Alternatively, open a terminal and type qgis to launch the application directly.

File:QGIS Interface.png
QGIS Desktop interface

Quick Start Guide

Understanding the QGIS Interface

The QGIS interface consists of several key components. The Map Canvas in the center displays your spatial data and is where most visualization occurs. The Layers Panel on the left shows all loaded layers in your project with options to toggle visibility and adjust order. The Browser Panel provides file system navigation for accessing spatial data. The Toolbars at the top contain buttons for common operations like zooming, selecting features, and measuring distances. The Status Bar at the bottom displays coordinate information, scale, and projection details.

Loading Your First Layer

To load spatial data, click Layer → Add Layer from the menu and choose the appropriate option based on your data type. For vector data like points, lines, or polygons, select Add Vector Layer and browse to your shapefile, GeoJSON, or GeoPackage file. For raster data like satellite imagery or elevation models, choose Add Raster Layer. The qgis/examples/01_loading_data.md file in our GitHub repository provides detailed instructions for various data formats.

Loaded layers appear in the Layers Panel and are drawn on the Map Canvas. Right-click any layer for additional options like viewing the attribute table, adjusting symbology, or accessing layer properties.

Basic Navigation

Use the navigation tools to explore your data. The Pan tool (hand icon) lets you move around the map by clicking and dragging. The Zoom In and Zoom Out tools magnify or reduce the view. Zoom to Layer extent shows the full extent of a selected layer. The mouse wheel also zooms in and out centered on the cursor position. The status bar shows your current position coordinates as you move the mouse across the map.

Working with Coordinate Reference Systems

Understanding coordinate systems is crucial in GIS work. Every spatial dataset has a Coordinate Reference System or CRS that defines how coordinates relate to locations on Earth. QGIS displays the current project CRS in the bottom right corner. Click it to change the project CRS. To check or change a layer's CRS, right-click the layer, select Properties, and go to the Source tab. The qgis/examples/02_coordinate_systems.md guide explains common CRS choices and when to use them.


Common Tasks

Task 1: Creating Thematic Maps

Thematic maps visualize spatial patterns in your data through color, size, or symbols. The qgis/examples/03_thematic_mapping.md guide demonstrates opening a vector layer with attributes, accessing layer properties by right-clicking and selecting Properties, navigating to the Symbology tab, choosing a rendering style such as Categorized for discrete values or Graduated for continuous data, selecting the attribute column to visualize, choosing a color ramp that effectively communicates your data, clicking Classify to generate classes, and adjusting class breaks or colors as needed.

Once styled, add a legend through Project → New Print Layout and insert Add Legend to create a complete map suitable for reports or publications.

Task 2: Spatial Analysis with Buffers

Buffer analysis creates zones around features at specified distances, useful for analyzing proximity relationships. The qgis/examples/04_buffer_analysis.md tutorial shows loading a point or line layer, opening the Processing Toolbox via Processing → Toolbox, searching for "buffer" to find the Buffer tool, setting the input layer and buffer distance in appropriate units, choosing an output location for the buffered layer, clicking Run to execute, and examining the resulting buffer zones on your map.

Buffers are fundamental for questions like "what is within 1 kilometer of this road" or "which houses are within 500 meters of the river".

Task 3: Raster Data Processing

Working with raster data like elevation models or satellite imagery requires specific tools. The qgis/examples/05_raster_processing.md guide demonstrates loading a raster layer, accessing raster tools through Raster menu, calculating hillshade from elevation data, performing reclassification to create categorical maps, conducting raster calculations using the Raster Calculator, clipping rasters to areas of interest, and changing color ramps to enhance visualization.

Raster processing can be computationally intensive. The cluster's resources allow you to work with large regional or even continental datasets that would be impractical on a desktop computer.

Task 4: Attribute Table Operations

The attribute table stores non-spatial information about features. The qgis/examples/06_attribute_operations.md tutorial shows opening the attribute table by right-clicking a layer and selecting Open Attribute Table, selecting features based on attributes using Select features using an expression, calculating new fields with the Field Calculator, editing existing attribute values, joining tables from different sources, and exporting selected features to new layers.

Understanding attribute operations is essential for querying and analyzing spatial data based on their characteristics.

Task 5: Geoprocessing Operations

QGIS provides numerous geoprocessing tools for spatial analysis. The qgis/examples/07_geoprocessing.md guide demonstrates clipping layers to study area boundaries, intersecting layers to find overlapping features, performing union operations to combine datasets, conducting spatial joins to transfer attributes between layers, dissolving features based on common attributes, and creating Voronoi polygons for proximity analysis.

These operations form the foundation of spatial analysis workflows, enabling complex questions about spatial relationships to be answered.


Tips & Best Practices

Data Management

Organize your GIS data in a clear folder structure with separate directories for raw data, processed outputs, and project files. Use GeoPackage format instead of shapefiles when possible as it stores multiple layers in a single file and has fewer limitations. Always maintain original data separately from processed versions. Document your data sources, processing steps, and coordinate systems in a project README or metadata file.

Store large raster datasets on the scratch directory at /scratch/username/ for better I/O performance during processing operations.

Performance Optimization

For large datasets, create spatial indexes to improve query and rendering speed by right-clicking the layer and selecting Properties → Source → Create Spatial Index. Simplify complex geometries when appropriate using Vector → Geometry Tools → Simplify to reduce vertex counts. Use layer filtering to display only relevant features rather than the entire dataset. Turn off layers not currently needed to improve map rendering speed. Save processing results to disk rather than keeping everything as temporary layers in memory.

Coordinate System Management

Always check that all layers in your project use appropriate coordinate systems. For analysis, ensure all layers are in the same projected CRS to avoid measurement errors. Use projected coordinate systems like UTM for local or regional analysis where distances and areas matter. Use geographic coordinate systems like WGS84 only for global-scale visualization. When creating new layers, explicitly set the CRS rather than relying on defaults.

The project CRS determines how layers are displayed but does not change the underlying data. Use Save As with a different CRS to actually reproject layers.

Quality Control

Verify data quality before analysis by checking for invalid geometries using Vector → Geometry Tools → Check Validity, looking for duplicate features, examining attribute completeness, confirming coordinate system correctness, and validating topology for features that should connect properly.

Use View → Panels → Log Messages to monitor processing operations and catch warnings or errors that might affect results.


Example Workflows

Example 1: Land Use Change Analysis

Objective: Compare land use or land cover between two time periods to identify areas of change.

Follow the complete workflow in qgis/workflows/01_land_use_change.md which demonstrates loading land use shapefiles or rasters for two different years, ensuring both datasets use the same coordinate system and extent, using Vector → Geoprocessing Tools → Intersection to identify areas present in both datasets, calculating area changes with the Field Calculator, creating a thematic map showing gains and losses in different land use categories, generating statistics summarizing change by category, and exporting results as maps and tables.

This workflow is valuable for environmental monitoring, urban planning, and understanding landscape dynamics over time.

Example 2: Site Suitability Analysis

Objective: Identify optimal locations for a facility based on multiple spatial criteria.

The qgis/workflows/02_suitability_analysis.md workflow shows defining your suitability criteria such as distance constraints, identifying necessary data layers including roads, water bodies, land use, and elevation, creating buffers around features to represent distance requirements, reclassifying raster data to suitability scores, using Raster Calculator to combine criteria with appropriate weights, identifying areas meeting all requirements, vectorizing suitable areas for further analysis, and validating results against ground truth or expert knowledge.

This approach is used in urban planning, renewable energy site selection, conservation planning, and facility location problems.

Example 3: GPS Data Visualization and Analysis

Objective: Import GPS tracking data, create visualizations, and analyze spatial patterns.

Follow qgis/workflows/03_gps_analysis.md which demonstrates loading GPX files using Layer → Add Layer → Add Vector Layer, selecting the appropriate GPS data type such as tracks, routes, or waypoints, styling tracks with appropriate colors and widths, adding a basemap using Web → QuickMapServices or XYZ tiles, calculating track statistics like distance and elevation gain, creating elevation profiles using the Profile Tool plugin, performing density analysis to identify frequently visited areas, and exporting finished maps for reports or presentations.

This workflow is applicable to wildlife tracking, recreational activity analysis, field survey data, and movement pattern studies.

Example 4: Satellite Imagery Processing

Objective: Process and analyze multispectral satellite imagery for land cover classification or change detection.

The qgis/workflows/04_satellite_imagery.md workflow demonstrates loading multispectral satellite bands as separate rasters, creating band composites using Raster → Miscellaneous → Build Virtual Raster, adjusting visualization with appropriate band combinations for different purposes, calculating vegetation indices like NDVI using Raster Calculator, performing supervised or unsupervised classification, assessing accuracy with ground truth data, creating change detection maps by comparing imagery from different dates, and exporting classified maps and statistics.

Remote sensing workflows benefit greatly from the cluster's computational resources when processing large scenes or time series.


Troubleshooting

Problem: Layers not displaying on map

If a loaded layer does not appear on the map canvas, first check that the layer is visible by looking for a checkmark in the Layers Panel. Verify the layer has a valid extent by right-clicking and selecting Zoom to Layer. If this fails, the layer may be empty or have invalid geometries. Check that the layer's coordinate system matches or is compatible with the project CRS. Look in View → Panels → Log Messages for error messages that might explain the problem.

Problem: CRS mismatch warnings

When loading layers with different coordinate systems, QGIS may display warnings about CRS mismatches. While QGIS can reproject layers on-the-fly for display, this can cause issues with measurements and analysis. For analysis work, ensure all layers are in the same projected coordinate system by saving them with Right-click → Export → Save Features As and selecting the target CRS. For viewing only, on-the-fly reprojection usually works fine.

Problem: Processing tools running very slowly

Slow processing usually indicates insufficient memory or very large datasets. Check available memory using system monitors. Simplify geometries before processing if vertex counts are very high. Process data in smaller chunks or tiles when possible. Use spatial indexes on all layers. Close other applications to free memory. For particularly large jobs, request more resources when launching your desktop session.

Problem: Unable to edit layer

If you cannot edit a layer, check that it is in a writable format. Layers from some sources like WFS services or database views may be read-only. Ensure editing is enabled by clicking the pencil icon in the toolbar. Verify you have write permissions for the file. For shapefiles, check that associated files like .shx and .dbf are present and writable. Try saving the layer to a new file with full permissions.

Problem: Basemaps not loading

If web basemaps from services like OpenStreetMap fail to load, verify your desktop session has internet connectivity by opening a web browser. Check the QGIS log for connection errors. Try different basemap providers through the QuickMapServices plugin. Some institutional networks block certain map services. For offline work, use locally stored basemap tiles or data.

Problem: Plugins not installing

Plugin installation requires internet access and may fail if the repository is unreachable. Check network connectivity. Try installing plugins manually by downloading from the QGIS plugin repository and using Plugins → Manage and Install Plugins → Install from ZIP. Some plugins require additional Python packages. Check the plugin documentation for dependencies. Contact KENET support if system Python packages need installation.


Additional Resources

The official QGIS documentation is available at https://docs.qgis.org/ and provides comprehensive guides covering all features and tools. The QGIS Training Manual at https://docs.qgis.org/latest/en/docs/training_manual/ offers structured tutorials for learning QGIS systematically. The QGIS community provides numerous video tutorials and blog posts covering specific workflows and techniques.

For spatial analysis concepts, consult textbooks on Geographic Information Systems or spatial statistics. The GDAL documentation at https://gdal.org/ is valuable for understanding raster and vector data formats and conversions. For coordinate systems, the EPSG database at https://epsg.io/ provides searchable information about projections worldwide.

Code Examples Repository: All code examples referenced in this tutorial are available at https://github.com/Materials-Modelling-Group/training-examples

For support, contact KENET at support@kenet.or.ke, consult the documentation at https://training.kenet.or.ke, or access the Open OnDemand portal at https://ondemand.vlab.ac.ke.


Feedback

If you encounter issues or have suggestions for improving this tutorial, please contact KENET support or submit feedback through the Open OnDemand interface using the feedback button.


Back to: Easy HPC access with KENET Open OnDemand