{"id":13948573,"url":"https://github.com/smnorris/fwapg","last_synced_at":"2025-04-14T00:55:04.833Z","repository":{"id":39725336,"uuid":"185426100","full_name":"smnorris/fwapg","owner":"smnorris","description":"PostgreSQL tools for working with British Columbia's Freshwater Atlas","archived":false,"fork":false,"pushed_at":"2025-04-01T21:41:05.000Z","size":9905,"stargazers_count":9,"open_issues_count":30,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T02:01:43.252Z","etag":null,"topics":["british-columbia","freshwater-atlas","fwa","lakes","linear-referencing","postgis","rivers","streams","watersheds"],"latest_commit_sha":null,"homepage":"https://smnorris.github.io/fwapg","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smnorris.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-07T15:07:42.000Z","updated_at":"2025-04-01T21:41:08.000Z","dependencies_parsed_at":"2024-02-08T01:22:52.240Z","dependency_job_id":"6740885c-1b23-44a4-ae2b-a9f0e00c68e1","html_url":"https://github.com/smnorris/fwapg","commit_stats":{"total_commits":442,"total_committers":2,"mean_commits":221.0,"dds":0.03167420814479638,"last_synced_commit":"9500b61f22fe8d4ae6059bbba3e3e5d97cb9899d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smnorris%2Ffwapg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smnorris%2Ffwapg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smnorris%2Ffwapg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smnorris%2Ffwapg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smnorris","download_url":"https://codeload.github.com/smnorris/fwapg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247581614,"owners_count":20961807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["british-columbia","freshwater-atlas","fwa","lakes","linear-referencing","postgis","rivers","streams","watersheds"],"created_at":"2024-08-08T05:01:25.098Z","updated_at":"2025-04-14T00:55:04.824Z","avatar_url":"https://github.com/smnorris.png","language":"PLpgSQL","funding_links":[],"categories":["Hydrosphere"],"sub_categories":["Freshwater and Hydrology"],"readme":"# fwapg\n\n`fwapg` extends British Columbia's [Freshwater Atlas](https://www2.gov.bc.ca/gov/content/data/geographic-data-services/topographic-data/freshwater) (FWA) with PostgreSQL/PostGIS. `fwapg` provides additional tables, indexes and functions to:\n\n- quickly translate arbitrary point locations (`X,Y`) to a linear reference positions (`blue_line_key, measure`) on the stream network\n- enable speedy upstream/downstream queries throughout BC\n- quickly and cleanly generate watershed boundaries upstream of arbitrary locations\n- enable cross-boundary queries by combining FWA data with data from neighbouring jurisdictions\n- enable querying of FWA features via spatial SQL\n- provide `gradient` values for every FWA stream\n- enable quickly serving FWA features as vector tiles (MVT)\n- enable quickly serving FWA features and custom fwapg functions\n- link additional data to FWA streams (PCIC mean annual discharge, modelled channel width, upstream precipitation)\n\nSee [documentation](https://smnorris.github.io/fwapg/) for setup and usage details, plus table and function references.\n\n\n## Quickstart\n\n1. Ensure all requirements/dependencies are met/installed:\n    - access to a PostgreSQL (13-16, 17 is not yet supported) database with the PostGIS extension (\u003e=3.1) installed\n    - GDAL \u003e=3.4\n    - Python 3\n    - [`bcdata`](https://github.com/smnorris/bcdata)\n    - [`make`](https://www.gnu.org/software/make/)/`unzip`/`curl`/`awscli`/ etc (see Dockerfile)\n\n2. Ensure you have a `DATABASE_URL` environment variable set to point to your database, for example:\n\n        export DATABASE_URL=postgresql://username:password@localhost:5432/fwapg\n\n3. Get scripts, load and optimize the data:\n\n        git clone https://github.com/smnorris/fwapg.git\n        cd fwapg\n        make\n\nThe full load takes some time - but once complete, you can run `fwapg` enabled queries with your favorite sql client. For example:\n\n*Locate the nearest point on the FWA stream network to a X,Y location on Highway 14:*\n\n        SELECT \n          gnis_name, \n          blue_line_key, \n          downstream_route_measure\n        FROM FWA_IndexPoint(ST_Transform(ST_GeomFromText('POINT(-123.7028 48.3858)', 4326), 3005));\n\n          gnis_name  | blue_line_key | downstream_route_measure\n        -------------+---------------+--------------------------\n         Sooke River |     354153927 |        350.2530543284006\n\n*Generate the watershed upstream of this location:*\n\n        SELECT ST_ASText(geom) FROM FWA_WatershedAtMeasure(354153927, 350);\n\n         st_astext\n        --------------\n        POLYGON((...\n\n*Select all stream upstream of this location:*\n\n        SELECT ST_ASText(geom)\n        FROM FWA_UpstreamTrace(354153927, 350);\n\n         st_astext\n        --------------\n        LINESTRINGZM((...\n\n\nSee [Usage](https://smnorris.github.io/fwapg/02_usage.html) for more examples.\n\n\n## Tile and feature services\n\n`fwapg` features and functions are served from hillcrestgeo.ca as GeoJSON or vector tiles via these web services and wrappers:\n\n- [features.hillcrestgeo.ca/fwa](https://features.hillcrestgeo.ca/fwa): tables and functions served as GeoJSON\n- [fwapgr (R)](https://github.com/poissonconsulting/fwapgr): an R wrapper around the `features.hillcrestgeo.ca/fwa` feature service\n- [fwatlasbc (R)](https://github.com/poissonconsulting/fwatlasbc): an R package for higher level queries\n- [tiles.hillcrestgeo.ca/bcfishpass](https://tiles.hillcrestgeo.ca/bcfishpass): FWA features (and others) served as vector tiles (MVT)\n\n\n## Source data\n\n- BC Freshwater Atlas [documentation](https://www2.gov.bc.ca/gov/content/data/geographic-data-services/topographic-data/freshwater) and [license](https://www2.gov.bc.ca/gov/content/data/open-data/open-government-licence-bc)\n\n- USGS Watershed Boundary Dataset (WBD) [Metadata](https://prd-tnm.s3.amazonaws.com/StagedProducts/Hydrography/WBD/National/GDB/WBD_National_GDB.xml)\n\n- Hydrosheds [License and citation](https://www.hydrosheds.org/page/license)\n\n\n## Development and testing\n\nExtremely basic tests are included for selected functions.\nIf changing a covered function, run the individual test. For example:\n\n    psql -f tests/test_fwa_upstream.sql\n\nAll results should be true.\n\n## Documentation\n\nDocumentation is built from the markdown files in `/docs`.\nInfo in the table reference page (`03_tables.md`) can be autogenerated from comments in the database. To dump the text to stdout:\n```\ncd docs\n./table_reference.sh \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmnorris%2Ffwapg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmnorris%2Ffwapg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmnorris%2Ffwapg/lists"}