Wednesday, December 17, 2025

Delete a table or layer from GeoPackage within QGIS

 To delete a table (layer) from a GeoPackage within QGIS, you can use either the Browser panel or the DB Manager.


Method 1: Using the Browser Panel

  1. This is the simplest and most direct way to delete a single table.
  2. Open the Browser panel: If it's not already visible, go to the top menu and select View > Panels > Browser Panel.
  3. Navigate to the GeoPackage: In the Browser panel tree, find the GeoPackage file (.gpkg) you are working with.
  4. Expand the GeoPackage: Click the arrow next to the GeoPackage name to view all the layers (tables) it contains.
  5. Delete the layer: Right-click on the specific layer/table you want to remove and select Delete Layer.
  6. Confirm the deletion: A confirmation window will appear; confirm that you want to delete the layer. 


Method 2: Using the DB Manager

The DB Manager provides a more database-oriented interface and is useful for managing multiple tables or running SQL commands. 

  1. Open the DB Manager: Go to the top menu and select Database > DB Manager.
  2. Connect to the GeoPackage: In the left-hand tree, expand GeoPackage. Right-click on GeoPackage and select New Connection, then browse to your .gpkg file.
  3. Find the table: Expand the connection to your GeoPackage and locate the desired table under Tables or Spatial tables.
  4. Delete the table: Right-click on the table name and select Delete.

That is it!

Saturday, December 6, 2025

CASE expression in QGIS

Understanding QGIS Expressions

A QGIS Expression is a combination of one or more values, operators, and functions that is evaluated dynamically within the context of a QGIS project.

The syntax for the QGIS Expression language is derived from Structured Query Language (SQL).

QGIS Expressions are utilized extensively throughout the QGIS environment, making familiarity with them essential for a wide range of geospatial tasks. Their applications include, but are not limited to:-

  1. Mapping and Symbology: Manipulating symbology and labels to create sophisticated, data-driven visual representations.
  2. Data Analysis and Management: Selecting features based on specific criteria, and generating new columns or updating existing ones in the attribute table.
  3. Feature Management: Creating new geometries using the Geometry Generator tool or calculating spatial attributes.
  4. Data Exploration: Filtering and querying data for rapid exploration and analysis.


The Syntax

  • (1) 'name' means a string text name
  • (2) "name" means a attribute column called name for the curent feature
  • (3) @name means a variable value called name. This used to be $name in older version of QGIS.
  • (4) name() means a function called name





The CASE expression in QGIS provides conditional logic, allowing the assignment of different values or the execution of different actions based on whether specified conditions are met. This is particularly useful in the Field Calculator, for data-defined properties, or within expressions used for labeling and symbology.


CASE

WHEN "NAME" IN ('New Caledonia', 'Jamaica', 'Bolivia', 'Suriname', 'Dem. Rep. Congo', 'Iraq') THEN "WB_A3" 

END