VeinsOfTheEarth / rabpro

Delineating watershed basins and computing attribute statistics using Google Earth Engine
https://VeinsOfTheEarth.github.io/rabpro
BSD 3-Clause "New" or "Revised" License
35 stars 8 forks source link

JOSS review: Is there a map/code somewhere which shows/maps a user coordinate to a corresponding MERIT tile? #131

Closed kanishkan91 closed 2 years ago

kanishkan91 commented 2 years ago

Let me know if I am missing something here. In the workflow example here- https://veinsoftheearth.github.io/rabpro/examples/notebooks/basic_example.html, a user can delinate a watershed based on random co-ordinates. But they would have to read in the corresponding tile from the MERIT files. I know that regular users would have all the MERIT tiles processed. But is there a way, a user can locate the corresponding MERIT tile for a co-ordinate? And in case you have a coordinate that does not have a corresponding MERIT tile for some reason, you get a warning or error? I think this would be a useful addition even for test cases and such.

Please only consider this a suggestion in case I am missing something fundamental.

https://github.com/openjournals/joss-reviews/issues/4237

jonschwenk commented 2 years ago

The user must download all the relevant MERIT tiles that cover their watershed of interest. The MERIT-Hydro page provides a gridded global map of their tiling scheme: http://hydro.iis.u-tokyo.ac.jp/~yamadai/MERIT_Hydro/. Under the hood, rabpro will stitch all downloaded tiles together into a virtual raster, so the user doesn't need to worry about matching tiles to coordinates.

If I'm reading correctly, you're suggesting a function that specifies a MERIT tile for a given coordinate. Fortunately, we already have this function. From the Data Configuration docs:

You can do this following the logic in the MERIT Hydro documentation or use the rabpro function rabpro.utils.coords_to_merit_tile to obtain a tile identifier (e.g. n30e150) which you can pass to the download_merit_hydro function

As you suggest, some coordinates do not have associated MERIT tiles (oceans). There could also be the case of someone accidentally flipping latitude and longitude or other miskeys. We do not have a check for those cases and it would be a little tricky to build this correctly. If a user provides a coordinate for which there is no data (e.g. -200, 200), rabpro's current behavior will simply tell the user that no suitable flowlines could be found. Agree that it would be nice to implement this feature to let the user know that there is no MERIT tile for the requested coordinate, but we think the current method provides at least enough of a hint for the user to doublecheck their inputs.

However, I would like to leave this open as an issue for future development--would be very handy and likely save some users lots of frustrating debugging!

kanishkan91 commented 2 years ago

@jonschwenk This all sounds good to me. If possible, could you also mention the usage of rabpro.utils.coords_to_merit_tile() on the Basic example page (maybe just add it to the code example there - https://veinsoftheearth.github.io/rabpro/examples/notebooks/basic_example.html)? Its an important function IMO.

Also, sorry to fixate on this more but does this function- rabpro.utils.coords_to_merit_tile() throw a warning when it can't find a tile? Even that would be very useful.