I am currently working on converting netCDF data to JSON in order to use it with leaflet-velocity. This tool follows the same format as the output of grib2json used by cambecc in earth. An example of sample JSON data can be found at wind-global.json.
By using netCDF4, I have successfully extracted latitude/longitude wind data arrays from my netCDF file.
I am curious about how the "data" part of the JSON file (as shown in the example below) is structured. It appears to be a lengthy array of values (e.g. for 'eastward wind' in the sample), but I am unsure of how these values are mapped to latitude/longitude coordinates later on.
Does the JSON header contain information that guides Leaflet on structuring the output, or does another function in leaflet-velocity.js handle this task?
I came across a related post on Stack Overflow which provided some clues, but I have been struggling for quite some time now to adapt it to my own netCDF file. The link to the question is here.
[
{
"header": {
"parameterUnit": "m.s-1",
"parameterNumber": 2,
"dx": 1.0,
"dy": 1.0,
"parameterNumberName": "eastward_wind",
"la1": -7.5,
"la2": -28.5,
"parameterCategory": 2,
"lo2": 156.0,
"nx": 14,
"ny": 22,
"refTime": "2017-02-01 23:00:00",
"lo1": 143.0
},
"data":[
-2.12,
-2.27,
-2.41,
...
]
}
]