pacificclimate / scip-backend

Backend that serves salmon population data to the scip webpage
GNU Affero General Public License v3.0
0 stars 0 forks source link

Initial version #1

Closed corviday closed 1 year ago

corviday commented 1 year ago

This is the first version of the salmon project data server. It's role is to provide location information about both predefined locations that may be of user interest ("regions") and the domain and status of salmon ("populations"). It gets information from a postGIS database and provides it to the SCIP frontend.

It looks like a lot of files, but there are only two APIs, region and population. The rest are just miscellaneous project setup: testing, documentation, github actions, etc.

corviday commented 1 year ago

Here are some demo links:

list all watersheds

list all chum salmon populations

which watershed is Hope, BC in?

what salmon populations are present in Hope, BC?

jameshiebert commented 1 year ago

My initial inclination is to ask to what degree do the geographic extents of the two API overlap and what type of response one can expect from an API call using a location that may not have data to support it.

I ask because the first thing that I did was look at the Chum Salmon API call that you provided in the PR.

Then looking at Conservation Unit coded as cu_code="CM-25" and cu_name="North Haida Gwaii-Stanley Creek", I made an API call to the the watershed API with the coordinate therein and received what was essentially an empty response.

$ curl 'http://docker-dev02.pcic.uvic.ca:30203/api/region?kind=watershed&overlap=POINT(-132.736911989%2053.991422278)'
[]

Ideally, the watershed API would at least acknowledge that it didn't have data available to return a response for that specific point.

The population API call, OTOH returned results from that CU as expected.

corviday commented 1 year ago

@jameshiebert I suspect this is a matter of missing data. There were some "watersheds" that were made up of a bajillion tiny islands and my extremely crude put-watersheds-in-the-database script can not yet handle them. My guess would be that there is an official Freshwater Atlas watershed for that region but that I have not yet added it to the database. (There is also the separate issue of where the "outlet" of a "watershed" made of disconnected land chunks is, but outlets are optional.)

I haven't put much time into that issue yet, because I think the first phase of this project is for the Fraser watershed only. We won't have climate data for other watersheds for a while, so if someone selected Haida Gwai they wouldn't be able to see streamflow projections anyway, and the current web front end only allows viewing the Fraser watershed. And I don't know if the PCEX backend can handle a multipolygon - I think the PDP doesn't, but unsure about PCEX.

I believe both the Freshwater Atlas watersheds and the Conservation Unit data are available for all BC, so if I can solve the multi-island issue, this API and the postGIS database could have all-BC coverage. If filling the data gap is important, I could move it up my priority queue.

Do you have a suggestion on what the API should do when there are no qualifying regions?

jameshiebert commented 1 year ago

Do you have a suggestion on what the API should do when there are no qualifying regions?

Probably a 404 with as much information as possible (e.g. whether the client point is outside of the extant of the data available, or something like that, wrong CRS or something).