IHCantabria / Leaflet.CanvasLayer.Field

Load and style Raster files in Leaflet (geotiff & asciigrid)
https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/
Other
183 stars 67 forks source link

How can I use it with WMS ? #82

Open aequorsolutions opened 2 years ago

aequorsolutions commented 2 years ago

Hello,

is it possible to use this plugins with data provided by WMS U and V components?

Thank you for the attention

VictorVelarde commented 2 years ago

Hi, short answer is no. WMS doesn't store U or V real values but usually just a visual encoding of those, in png, .jpg.., with some kind of r.g.b. color mapping to the original float value. WCS is the best choice.

The only possible path to something like that would be using some kind of manual procedure, to encode previously the real values in the RGB somehow (thus having control of the WMS server), with an approach similar to this: https://docs.mapbox.com/data/tilesets/reference/mapbox-terrain-rgb-v1/#elevation-data

aequorsolutions commented 2 years ago

Hi Victor, I'm trying to use NASA GIBS service which provide only WMS layers. Looking deeper, I found the origin of the wind and ocean currents data, but it provides only netCDF files via HTTP and OpenDAP. Do you have any sugestions on how to get this data to use with VectorField plugin?

I spend a lot of time on google but I cound not find anything useful.

VictorVelarde commented 2 years ago

Probably trying to find same dataset served by NASA under a Thredds server, which allows using WCS & geotiff, is the best option. I'm not sure exactly which dataset you require, but chances are that they are served that way in another url. Eg: https://thredds.jpl.nasa.gov/thredds/catalog.html ??

Reading netCDF & OpenDAP in the browser and prepare the field is something I've never tried. There are libs at npm (search for netcdf / opendap) but all look old & not well maintained (eg: https://www.npmjs.com/package/jsdap/v/5.0.0)

aequorsolutions commented 2 years ago

Hello Victor,

thank you very much for send the links. I found two datasets that are served with WCS.

https://thredds.jpl.nasa.gov/thredds/wcs/ocean_circulation/ALL_OSCAR_L4_OC_third-deg.nc?service=WCS&version=1.0.0&request=GetCapabilities

https://thredds.jpl.nasa.gov/thredds/wcs/ncml_aggregation/OceanWinds/smap/aggregate__SMAP_JPL_L3_WIND_SPEED_CAP_8DAY-RUNNINGMEAN_V5.ncml?service=WCS&version=1.0.0&request=GetCapabilities

The final question is how can I use the U and V data provide as WCS layers with the plugin? The example uses asc files, which makes it easy to use.

I appreciate very much for all the help.

VictorVelarde commented 2 years ago

Check code in this WCS example here to getCoverage for a variable: https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/example_ScalarField_Geotiff_WCS.html. You would need 2 combined requests for vectorField, one per each u | v component

aequorsolutions commented 2 years ago

Hi Victor,

Sorry for the stupid questions, I didn't see that there is an example with WCS

After a few hours of study and attempts, I managed to use the plugin with the products made available by NASA via thredds; However, the result was not quite as expected, the data were strange, with winds from the south across the globe (figure below)

I suspect it may be related to the CRS=EPSG:4326 argument that didn't work in the request.

This is the final urlCoverage I was able to use:

U: https://thredds.jpl.nasa.gov/thredds/wcs/ncml_aggregation/OceanWinds/ccmp/aggregate__CCMP_MEASURES_ATLAS_L4_OW_L3_5A_5DAY_WIND_VECTORS_FLK.ncml?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&COVERAGE=uwnd&TIME=2011-12-01T00:00:00Z&FORMAT=geotiff

V: https://thredds.jpl.nasa.gov/thredds/wcs/ncml_aggregation/OceanWinds/ccmp/aggregate__CCMP_MEASURES_ATLAS_L4_OW_L3_5A_5DAY_WIND_VECTORS_FLK.ncml?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&COVERAGE=vwnd&TIME=2011-12-01T00:00:00Z&FORMAT=geotiff

(Manually the browser downloads geotiff, but to run it in the application I had to disable CORS with the Chrome Access-Control-Allow-Origin extension)

Thank you again for all the help.

image

VictorVelarde commented 2 years ago

Looks like either the values inside are expressed in a non standard magnitude (usually m/s) or there is a problem in code combining both bands