Skip to content

Instantly share code, notes, and snippets.

View weblorin's full-sized avatar

Lorin weblorin

  • Canada
View GitHub Profile
@weblorin
weblorin / rsid.zsh
Created April 10, 2025 18:38
zsh to extract the riverscapes id from project.rs.xml at provided path (assumes current)
#!/bin/zsh
# Usage: ./rsid.zsh [optional_path] [--verbose]
# Get the directory path from the argument or use the current directory
DIR_PATH=${1:-$(pwd)}
# Check for the --verbose flag
VERBOSE=false
if [[ "$2" == "--verbose" ]]; then
@weblorin
weblorin / match_columns_metric_description.sql
Created April 10, 2025 17:06
Transform Riverscapes Metrics table data into geopackage gpkg_data_column values
WITH metric_info AS (
SELECT m.name AS object_name, p.name AS column_name, metrics.metric_id, m.type AS object_type, metrics.description, metrics.name as FriendlyColName
FROM sqlite_master AS m
JOIN pragma_table_info(m.name) AS p
LEFT JOIN metrics on p.name = metrics.field_name
WHERE m.type IN ('table', 'view') -- both tables and views
and m.name IN (select table_name FROM gpkg_contents) -- only tables/views registered as geopackage layers
)