Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Geological models require projected coordinate systems (meters), but input layers may use different CRS. This adds model-level CRS management with automatic transformation of all input layers.

Changes

CRS Storage & Validation (data_manager.py)

  • Added _model_crs and _use_project_crs fields with validation ensuring projected (not geographic) CRS
  • Persists CRS settings via to_dict()/from_dict()
  • Callback system for UI synchronization

Spatial Transformation (vectorLayerWrapper.py)

  • Enhanced qgsLayerToGeoDataFrame(layer, target_crs=None) to transform geometries when target_crs differs from layer CRS
  • Applied to all data workflows: basal contacts, structural orientations, fault traces, foliation data
  • Null-safe error handling with descriptive warnings

UI Controls (bounding_box.ui, bounding_box.py)

  • Added CRS selector with "Use Project CRS" (default) / "Use Custom CRS" radio buttons
  • Real-time validation preventing geographic CRS selection
  • Visual feedback for invalid selections

Model Initialization (geological_model_tab.py)

  • Blocks initialization if CRS is invalid or geographic
  • Clear error messages directing users to fix CRS in Model Definition tab

Example

# Before: layers used in their native CRS (could be geographic)
gdf = qgsLayerToGeoDataFrame(layer)

# After: automatically transforms to model CRS
model_crs = data_manager.get_model_crs()  # Validated projected CRS
gdf = qgsLayerToGeoDataFrame(layer, target_crs=model_crs)

Default behavior uses project CRS. Backward compatible - target_crs parameter is optional.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature Request] - convert layer crs to model crs</issue_title>
<issue_description>### Feature description

Allow for model to have a defined crs and convert all layers into this crs

Additional context

No response</issue_description>

<agent_instructions>Add the option for a model CRS, or use the project crs. Ensure the CRS is projected and not geographic (needs to be in meters). Then add appropriate functions to perform spatial transformation before the layers are used in the loopstructural code. This would be in the qgslayertogeopandasdataframe and assocaited functions. Add the CRS definition into the bounding box widget with a check box to use project CRS or another to use a specific CRS. If the chosen mode is invalid don't allow for the model to be initialised.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 26, 2026 08:00
Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com>
Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com>
Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com>
Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com>
Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to convert layer CRS to model CRS Add model CRS with automatic spatial transformation Jan 26, 2026
@lachlangrose lachlangrose marked this pull request as ready for review January 26, 2026 23:26
@lachlangrose lachlangrose merged commit 1bef056 into dev-0.1.12 Jan 26, 2026
1 check passed
@lachlangrose lachlangrose deleted the copilot/add-model-crs-conversion branch January 26, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants