smnorris / fwapg

PostgreSQL tools for working with British Columbia's Freshwater Atlas
https://smnorris.github.io/fwapg
MIT License
9 stars 5 forks source link

fwa_indexpoint - add option to only return streams associated with the fundamental watershed in which the point occurs #86

Open smnorris opened 2 years ago

smnorris commented 2 years ago

This is unlikely to guarantee the function will only return streams that the point will flow to, but it should do so in the vast majority of cases.

smnorris commented 2 years ago

While a 'within_same_watershed' option for the function would be great, it is not so simple in many locations. Consider adjacent to double line rivers: https://features.hillcrestgeo.ca/fwa/collections/whse_basemapping.fwa_watersheds_poly/items.html?watershed_feature_id=8492825

If asking for only features within the watershed in which the point is found, the Cowichan would not be included in the results, just the side channel and a disconnected pond.

It might be better to encourage the user to cast a fairly wide net, return a few indicators about how the stream and point relate and let the user choose the best match (mostly because input points tend to be inaccurate anyway, user should generally be checking against several matches to see if they are getting the best stream, usually by name).

Otherwise, maybe options like this:

fwa_indexpoint(x,y,srid,tolerance,num_features, match_type, include_disconnected, include_null_localcodes)

Where match_type: nearest=return closest stream, flow=return only streams within same watershed or downstream include_disconnected: true = include 999 streams include_null_localcodes: true = include streams with null localcode

So, for general networking purposes, presuming input point is of good quality:

fwa_indexpoint(x, y, srid, 100, 1, flow, false, false) would give the best single result.

smnorris commented 2 years ago

Another issue with the function is that bc_ind is based only on intersection with watershed group polys. A better check is needed. A marine/terrestrial flag would be useful too.