# Section editor

Geological interpretation of profiles exported by GeoProfiler.

## What it does

The Section editor loads a geological profile from a GeoProfiler export database and turns it into a two-dimensional working space inside the ordinary QGIS map canvas: the horizontal axis is the distance along the profile (s), the vertical axis is the true elevation (z), with no vertical exaggeration. On this section plane the projected data exported by GeoProfiler become read-only reference layers, and the geological interpretation — horizons, faults and unit bodies — is drawn as ordinary editable vector layers, stored in the same GeoPackage as the export tables.

## Workflow

1. Open geoprofile database … — choose the database exported by GeoProfiler (command 5 - Export geoprofile of the GeoProfiler module), then the result set, the profiles, the kinds of geodata to show as backdrops, how to lay the sections out and the frame to draw around them.
2. Layout of the imported profiles — several profiles can be shown at once: one below the other (vertical), one beside the other (horizontal) or on a grid of the chosen number of columns. Each section is placed in its own part of the plane, every one of them keeping its own distance and elevation values: a section starting at distance zero is simply drawn at the x of its own origin. The gaps between them are chosen automatically unless set.
3. Load sections in project — the layers of each section appear in their own group, all of them under the qgSurf sections group, and the canvas zooms onto them. Loading again with a different layout moves the sections, the interpretation already drawn on them following along.
4. Choose the working profile in the drop-down list: the editing buttons, the frame controls and Zoom to working section act on that section alone, while all the others stay visible.
5. Section frame — change the grid steps or the elevations the frame spans, and Redraw frame to draw it again. A frame given a deeper bottom takes more room than the layout had given its section: the other sections move aside to keep clear of it, carrying along the interpretation drawn on them.
6. Edit horizons / Edit faults / Edit unit bodies — toggle editing on the interpretation layers and digitize with the standard QGIS tools (Add line feature, vertex tool, …). Pressing the button again saves the edits.

## The section layers

Backdrop layers (read-only, stored in the GeoPackage and rewritten from the export tables at every load, so a saved QGIS project reopens onto full layers):

- Topography — the topographic trace of the profile.
- Projected attitudes — each projected attitude is drawn as a short segment dipping with its apparent dip in the section plane (fields: apparent slope, down-dip sense, source dip direction and angle, distance to the profile, label).
- Projected points — the projected point data.
- Line intersections — the crossings of the intersected lines, marked on the topographic trace.
- Polygon intersections — the geological units crossed by the profile, as coloured bands following the topography.
- Section frame — the box enclosing the profile, with the elevation grid, the labelled ticks of the two axes and the name of the profile, written once above the box: the one the export gave it, so that a section can be told from the others. The box is grown outwards to round elevations, so the section is read against graduated axes instead of bare coordinates.

## How the section is coloured

A section is drawn with the graphic attributes GeoProfiler stored in the export, when it carries them: every geological unit — both its band of outcrop and the unit body seeded under it — is filled with the colour it has in the plot, and so on the geological map the plot read it from. The topography, the projected points and the line intersections keep the colours, widths and markers they were plotted with.

This is what keeps a section recognisable: without it the units are coloured from a palette of the section editor's own, assigned in alphabetical order, so the same unit can come out a different colour from one profile to the next. Uncheck Use the graphic attributes exported from GeoProfiler in the import dialog to go back to that palette. An export written by an earlier version of GeoProfiler carries no attributes, and the option is then not offered.

A unit the plot does not name — one whose outcrops the source symbology left unclassified — still gets a colour of its own from the palette, so no part of the section is ever left undrawn. The interpretation layers drawn by hand, Horizons and Faults, are coloured by their own type and kind: they have no counterpart in the plot.

## The categories, and the legend

The categories of a section are those of the source layers, whole: every class of the geological map the profiles were cut from, and every class of the intersected lines, whether or not this profile happens to cross it. A section is interpreted with the units of its map, and a unit met by no profile is one that may still have to be drawn at depth: it is there in the symbology, ready to be given to a body.

They are also the same categories in every section shown, and each of them is drawn the same way throughout: colours are resolved once for the whole result set, so a unit cannot come out one colour here and another one there. An export written by an earlier version of GeoProfiler does not carry the source classification; the categories are then gathered from all the loaded profiles together, which still keeps them common to every section.

Draw a legend beside the sections puts the swatches to the right of the layout — one per category, in the order of the source layer legend, with the category name beside it — under the Legend group of the layer tree: Units legend for the geological units and Line intersections legend for the line categories. The two stand side by side, each as a column starting at the top, so that a long classification does not run past the bottom of the sections; a column is as wide as its longest name, which is what keeps the next one clear of it. Swatches and names alike are sized against the sections, so the legend holds together at every zoom. It is one legend for every section shown, and it moves and is resized with them when the layout or a frame changes.

## Changing the styles

The renderers are ordinary QGIS symbology: whatever a section starts out with can be changed in the usual way. A change made to a category — on the legend layer, on the unit bodies, on the outcrop bands or on the line intersections — is handed to every other layer of its family at once, so the sections stay in step with each other and with the legend. The outcrop bands are lines where the unit bodies are fills, and take the colour of each category rather than the whole symbol.

The styles chosen this way are stored in the GeoPackage, for the result set and not for the profile, and are put back the next time the sections are loaded, in a later session too: being the more recent word, they win over the attributes the export carries. Reset the category styles drops them and draws the categories again as the export has them.

The frame has four parameters, all in the units of the profile: the elevation grid step, the distance tick step, and the bottom and top the box spans. A step left to the automatic choice graduates its axis into about eight round divisions; a bottom or top left to the profile takes the elevation range of the topography.

The bottom and the top only ever extend the box — a bottom below the profile lowers it, making room for the interpretation at depth, while one above the profile is ignored, a box cutting through the topography being of no use — and both are then rounded outwards to the grid.

The four values can be set in the import dialog and changed at any time in the Section frame group of the panel: Redraw frame draws the frame again without reloading the sections and without touching the interpretation, and reports underneath the extent actually drawn, the automatic choices resolved. They belong to the working profile alone: the other sections keep the frame they have. They are stored in the GeoPackage, indexed by profile (`gp_section_frame_params`), so the frame comes back as it was left, in a later session too.

Where each section sits in the plane is stored beside its frame, in the same table (`origin_x`, `origin_y`): sections are not fixed where a load put them. Whenever the room one of them needs changes — a reload with another layout, a frame given a deeper bottom — they are placed again, and everything drawn on them is moved along, so that a distance along a profile stays recoverable as x minus the origin of its section.

Editable layers (stored in the GeoPackage, one record set per profile):

- Horizons — geological boundaries, with name, type (top, base, unconformity, intrusive contact, generic), units above/below and confidence.
- Faults — fault traces, with name, kind (normal, reverse, thrust, strike-slip, oblique), apparent movement sense in the section (down-right, down-left, dextral, sinistral) and confidence.
- Unit bodies — the geological units as polygons. The polygon intersections are turned once into starting bodies: the outcrop band along the topography, closed downward by a shallow flat bottom, to be reshaped into the interpreted body at depth. The bands of a same unit that touch one another become a single body, the boundaries between the map polygons they come from not being geological ones; the same unit met again beyond another one stays a body of its own. Bodies already present are never recreated, so the edited shapes survive every reload.

## Geology-aware drawing

When a section is loaded, snapping is configured on the attitude segments, the topography and the interpretation layers (vertices and segments). Since each attitude segment already dips with its apparent dip, snapping a horizon vertex onto — or along — a projected attitude yields a trace consistent with the measured orientation; snapping to the topography anchors boundaries where they crop out.

## Storage and sessions

The interpretation lives in three GeoPackage layers, `gp_section_horizons`, `gp_section_faults` and `gp_section_units`, next to the `gp_*` export tables, and every feature is keyed to its profile and result set. The backdrops are stored in the GeoPackage as well (`gp_section_topography`, `gp_section_frame` and companions), as derived layers rewritten at every load. Reloading the same profile — in a later QGIS session too — restores the interpretation drawn for it, and a saved QGIS project reopens complete.

GeoProfiler writes its export database as a plain SQLite file, which cannot hold spatial layers. When such a file is opened, the Section editor offers to copy it once into a GeoPackage twin (same name, `.gpkg` extension) placed next to it, and works there; the original export file is left untouched. Later GeoProfiler exports can target the GeoPackage directly.

## Coordinates

The section layers live in a synthetic Cartesian plane (distance-elevation), not in a real-world reference system: mixing them with georeferenced layers is meaningless, and the module warns when the project holds any. A blank QGIS project per section interpretation is the practical setup; Zoom to working section and Zoom to all sections bring the canvas back onto the sections at any time. The coordinates of a section are those of its profile shifted by the origin the layout gave it, so a distance along the profile stays recoverable as x minus that origin.