Skip to content

Viewing Geotechnical Data in QGIS

In this guide, you will convert AGS files into a GeoPackage format that can be opened and visualized in QGIS. This process transforms specialized geotechnical data into standardized geospatial features that GIS software can understand.

Before starting, ensure you have:

  • Python installed with bedrock-ge package
    • We recommend using uv to manage Python
  • QGIS installed on your system
  • AGS files containing geotechnical data
  • Knowledge of your project’s coordinate reference system (CRS)

Install the required packages if you haven’t already:

Terminal window
uv add bedrock-ge geopandas

Step 2: Define Coordinate Reference Systems

Section titled “Step 2: Define Coordinate Reference Systems”

Identify the spatial reference systems used in your geotechnical data. You need both horizontal (projected) and vertical coordinate systems.

from pyproj import CRS
projected_crs = CRS("EPSG:2326") # Hong Kong 1980 Grid System
vertical_crs = CRS("EPSG:5738") # Hong Kong Principle Datum
# Other common examples:
# projected_crs = CRS("EPSG:27700") # OSGB36 / British National Grid (UK)
# vertical_crs = CRS("EPSG:5701") # Ordnance Datum Newlyn (UK)

Use EPSG.io to find the correct codes for your project location.

For a single AGS file, use this code to convert it to GeoPackage:

from pyproj import CRS
from bedrock_ge.gi.mapper import map_to_brgi_db
from bedrock_ge.gi.ags import ags_to_brgi_db_mapping
from bedrock_ge.gi.geospatial import create_brgi_geodb
from bedrock_ge.gi.write import write_brgi_db_to_file
projected_crs = CRS("EPSG:2326")
vertical_crs = CRS("EPSG:5738")
with open("your_data.ags") as ags_file:
brgi_mapping = ags_to_brgi_db_mapping(ags_file, projected_crs, vertical_crs)
brgi_db = map_to_brgi_db(brgi_mapping)
geodb = create_brgi_geodb(brgi_db)
write_brgi_db_to_file(geodb, "gi_data.gpkg", driver="GPKG")

When working with multiple AGS files from the same project:

import zipfile
from pathlib import Path
from pyproj import CRS
from bedrock_ge.gi.mapper import map_to_brgi_db
from bedrock_ge.gi.ags import ags_to_brgi_db_mapping
from bedrock_ge.gi.geospatial import create_brgi_geodb
from bedrock_ge.gi.write import write_brgi_db_to_file
from bedrock_ge.gi.db_operations import merge_dbs
projected_crs = CRS("EPSG:2326")
vertical_crs = CRS("EPSG:5738")
folder_path = Path("./ags_files")
ags_files = list(folder_path.glob("*.ags"))
ags_file_brgi_dbs = []
for file_path in ags_files:
print(f"Processing {file_path.name}...")
with open(file_path) as ags_file:
brgi_mapping = ags_to_brgi_db_mapping(ags_file, projected_crs, vertical_crs)
brgi_db = map_to_brgi_db(brgi_mapping)
ags_file_brgi_dbs.append(brgi_db)
merged_brgi_db = merge_dbs(ags_file_brgi_dbs)
geodb = create_brgi_geodb(merged_brgi_db)
write_brgi_db_to_file(geodb, "combined_gi_data.gpkg", driver="GPKG")
  1. Launch QGIS and create a new project

  2. Add the GeoPackage layer:

    • Go to Layer > Add Layer > Add Vector Layer
    • Set Source Type to “File”
    • Click Browse and select your .gpkg file
    • Click Add
  3. Select tables to load:

    • QGIS will show a dialog with available tables
    • Key tables include:
      • LonLatHeight: Ground investigation locations in WGS84 coordinates
      • Location: Borehole locations with 3D geometry
      • InSituTests_GEOL: Geological descriptions with depth intervals
      • InSituTests_ISPT: Standard Penetration Test results
      • InSituTests_WETH: Weathering grade information
    • Select the tables you want to visualize and click OK
  1. View location points:

    • The LonLatHeight table displays best as points on the map
    • Right-click the layer > Properties > Symbology
    • Choose appropriate symbols and colors
  2. Examine test results:

    • Tables like InSituTests_ISPT contain point data with test values
    • Use graduated symbols or colors based on values like ISPT_NVAL (SPT N-value)
  1. Filter data by values:

    • Right-click layer > Filter
    • Example: "ISPT_NVAL" BETWEEN 1 AND 10 to show soft soils
    • Example: "WETH_GRAD" NOT LIKE '%V%' to show competent rock
  2. Create thematic maps:

    • Use Properties > Symbology > Graduated
    • Classify by geological or geotechnical parameters
    • Apply color ramps to visualize spatial patterns

The converted data includes 3D geometries representing boreholes and test intervals:

  1. Enable 3D view:

    • Go to View > 3D Map Views > New 3D Map View
    • Configure terrain and layer elevation properties
  2. Vertical profiles:

    • Use QGIS plugins like Profile Tool to create cross-sections through boreholes
    • Examine geological layers and test results along specific alignments

The GeoPackage contains multiple related tables:

  • Project: Project-level information
  • Location: Borehole/test locations with coordinates and ground levels
  • LonLatHeight: Location points in WGS84 for web mapping compatibility
  • InSituTests_: Various in-situ test results (GEOL, ISPT, WETH, etc.)
  • Samples: Sample information if available in source data
  • LabTests_: Laboratory test results if available

Each table includes:

  • Geometry: 3D points or lines representing spatial location and depth
  • Attributes: Test results, descriptions, and metadata
  • Relationships: Links between projects, locations, samples, and tests

After visualizing your data in QGIS, you can:

  • Export styled maps as images or PDFs
  • Perform spatial analysis using QGIS geoprocessing tools
  • Integrate with other geospatial datasets
  • Share data through web services or export to other formats
  • Use QGIS plugins for specialized geotechnical analysis

No geometry displayed: Ensure your coordinate reference systems are correct and match your data location.

Empty or missing data: Check that your AGS files contain location coordinates and the required data groups.

Coordinate system issues: Verify the EPSG codes match your project’s spatial reference systems using EPSG.io.

Large file performance: For projects with many boreholes, consider loading only essential tables initially.