fwapg

PostgreSQL tools for working with British Columbia's Freshwater Atlas

https://github.com/smnorris/fwapg

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary

Keywords

british-columbia freshwater-atlas fwa lakes linear-referencing postgis rivers streams watersheds
Last synced: 6 months ago · JSON representation

Repository

PostgreSQL tools for working with British Columbia's Freshwater Atlas

Basic Info
Statistics
  • Stars: 9
  • Watchers: 3
  • Forks: 4
  • Open Issues: 29
  • Releases: 14
Topics
british-columbia freshwater-atlas fwa lakes linear-referencing postgis rivers streams watersheds
Created almost 7 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

fwapg

fwapg extends British Columbia's Freshwater Atlas (FWA) with PostgreSQL/PostGIS. fwapg provides additional tables, indexes and functions to:

  • quickly translate arbitrary point locations (X,Y) to a linear reference positions (blue_line_key, measure) on the stream network
  • enable speedy upstream/downstream queries throughout BC
  • quickly and cleanly generate watershed boundaries upstream of arbitrary locations
  • enable cross-boundary queries by combining FWA data with data from neighbouring jurisdictions
  • enable querying of FWA features via spatial SQL
  • provide gradient values for every FWA stream
  • enable quickly serving FWA features as vector tiles (MVT)
  • enable quickly serving FWA features and custom fwapg functions
  • link additional data to FWA streams (PCIC mean annual discharge, modelled channel width, upstream precipitation)

See documentation for setup and usage details, plus table and function references.

Quickstart

  1. Ensure all requirements/dependencies are met/installed:

    • access to a PostgreSQL (13-16, 17 is not yet supported) database with the PostGIS extension (>=3.1) installed
    • GDAL >=3.4
    • Python 3
    • bcdata
    • make/unzip/curl/awscli/ etc (see Dockerfile)
  2. Ensure you have a DATABASE_URL environment variable set to point to your database, for example:

    export DATABASE_URL=postgresql://username:password@localhost:5432/fwapg
    
  3. Get scripts, load and optimize the data:

    git clone https://github.com/smnorris/fwapg.git
    cd fwapg
    make
    

The full load takes some time - but once complete, you can run fwapg enabled queries with your favorite sql client. For example:

Locate the nearest point on the FWA stream network to a X,Y location on Highway 14:

    SELECT 
      gnis_name, 
      blue_line_key, 
      downstream_route_measure
    FROM FWA_IndexPoint(ST_Transform(ST_GeomFromText('POINT(-123.7028 48.3858)', 4326), 3005));

      gnis_name  | blue_line_key | downstream_route_measure
    -------------+---------------+--------------------------
     Sooke River |     354153927 |        350.2530543284006

Generate the watershed upstream of this location:

    SELECT ST_ASText(geom) FROM FWA_WatershedAtMeasure(354153927, 350);

     st_astext
    --------------
    POLYGON((...

Select all stream upstream of this location:

    SELECT ST_ASText(geom)
    FROM FWA_UpstreamTrace(354153927, 350);

     st_astext
    --------------
    LINESTRINGZM((...

See Usage for more examples.

Tile and feature services

fwapg features and functions are served from hillcrestgeo.ca as GeoJSON or vector tiles via these web services and wrappers:

Source data

Development and testing

Extremely basic tests are included for selected functions. If changing a covered function, run the individual test. For example:

psql -f tests/test_fwa_upstream.sql

All results should be true.

Documentation

Documentation is built from the markdown files in /docs. Info in the table reference page (03_tables.md) can be autogenerated from comments in the database. To dump the text to stdout: cd docs ./table_reference.sh

Owner

  • Name: Simon Norris
  • Login: smnorris
  • Kind: user
  • Location: British Columbia
  • Company: Hillcrest Geographics

GitHub Events

Total
  • Issues event: 15
  • Delete event: 5
  • Issue comment event: 17
  • Push event: 58
  • Pull request event: 10
  • Create event: 9
Last Year
  • Issues event: 15
  • Delete event: 5
  • Issue comment event: 17
  • Push event: 58
  • Pull request event: 10
  • Create event: 9

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 461
  • Total Committers: 2
  • Avg Commits per committer: 230.5
  • Development Distribution Score (DDS): 0.03
Past Year
  • Commits: 29
  • Committers: 1
  • Avg Commits per committer: 29.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Simon Norris s****s@h****a 447
franTarkenton k****n@g****a 14
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 110
  • Total pull requests: 27
  • Average time to close issues: 2 months
  • Average time to close pull requests: 3 days
  • Total issue authors: 5
  • Total pull request authors: 2
  • Average comments per issue: 1.22
  • Average comments per pull request: 0.04
  • Merged pull requests: 22
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 12
  • Pull requests: 10
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 7 days
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 1.25
  • Average comments per pull request: 0.1
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • smnorris (103)
  • joethorley (3)
  • paddleman (1)
  • NewGraphEnvironment (1)
  • heckstra (1)
Pull Request Authors
  • smnorris (29)
  • franTarkenton (1)
Top Labels
Issue Labels
bug (24) enhancement (9) data (2)
Pull Request Labels

Dependencies

docs/requirements.txt pypi
  • myst_parser *
  • sphinx_rtd_theme *
.github/workflows/build-docker-image.yml actions
  • actions/checkout v3 composite
  • docker/build-push-action f2a1d5e99d037542a71f64918e516c093c6f3fc4 composite
  • docker/login-action 65b78e6e13532edd9afa3aa52ac7964289d1a9c1 composite
  • docker/metadata-action 9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 composite
.github/workflows/build-docs.yml actions
  • actions/checkout master composite
  • ad-m/github-push-action master composite
  • erpcya/sphinx-action feature/#update-sphinx-base-image composite
Dockerfile docker
  • ghcr.io/osgeo/gdal ubuntu-small-3.8.0 build
docker-compose.yml docker
  • postgis/postgis 16-3.4
  • pramsey/pg_featureserv latest
  • pramsey/pg_tileserv latest