cywhale / gebco

FastAPI of GEBCO bathymetry
5 stars 0 forks source link

Getting gridded data #1

Closed bjorkqvi closed 8 months ago

bjorkqvi commented 9 months ago

I have been needing a python friendly way to read in GEBCO bathymetry data, and this seems to be really close to what I need.

As I see it, this command ('https://api.odb.ntu.edu.tw/gebco?lon=4,6&lat=60.0,59.0&mode=row') gives me a NE-SW slice with 15-arcsec resolution. Is there a way to get the data gridded for that area with the same 15-arcsec resolution in both lon and lat direction?

I could trivially read a lot of slices, but then I need to specify the resolution, and it seems like a bit of a hack.

Thanks!

cywhale commented 9 months ago

Please try polygon mode that specified by GeoJSON in jsonsrc parameter

https://api.odb.ntu.edu.tw/gebco?mode=zonly&sample=1&jsonsrc={"type": "Polygon", "coordinates": [[ [4, 60.0], [6, 60.0], [6, 59.0], [4, 59.0], [4, 60.0]]]}

Here zonly in mode means output z data only, no pairwise distance, optional. In polygon mode, we would not output pairwise distance, so it should speedup processing. Add row in the parameter mode separated by comma if you need this format (i.e., ?mode=zonly,row) The parameter sample for polygon mode is default 5, means down-sampling 5 times in both x, y direction. That's because the data output is quite huge. But if you just want the 15-arcseconds resolution, adjust sample to 1 in this polygon mode. Default sample is 1 in other normal modes.

Multiple features are allowed:

https://api.odb.ntu.edu.tw/gebco?mode=zonly&jsonsrc={"type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [4, 60.0], [6, 60.0], [6, 59.0], [4, 59.0], [4, 60.0] ] ] } }]}
bjorkqvi commented 9 months ago

Many thanks, this seems to work like a charm!

I'm thinking about including this as a part of a GEBCO reader in an upcoming version of a downscaling software we are working on (https://github.com/MET-OM/dnora). Is it ok to write our software to use that web address directly?

cywhale commented 9 months ago

Please. Just use it if it suits your work. Any feedbacks or features required are welcome. DNORA looks promising. I just think recently I developed my tide API (use TPXO9_altas_v5 model, also in my github) and used one tide data from Norwegian Meteorological Institute to verify. I'm interested in surveying such forcasting tools more. I'm happy if the gebco API can help in this tool.

BTW, If you finally adopt this gebco API, and can give a credit to ODB somewhere in your documentation, please use

Ocean Data Bank, National Science and Technology Council, Taiwan. https://doi.org/10.5281/zenodo.7512112. Accessed from api.odb.ntu.edu.tw/gebco. v1.0.

Never mind if you would not write doc for using it.

cywhale commented 8 months ago

Add the polygon mode in README.md. Close it. Feel free to reopen it if any questions.