I am converting weather radar data (grib2) to raster tiles for Mapbox. The resulting tiles are mis-aligned from the original grib2 data and I am not sure why. I have a 4-step process using GDAL in the command line to convert the grib2 to raster tiles, which I will go into great detail below. The weather data provider provides an online viewer for their data, so I was able to make an example by matching the zoom and capturing the difference :
I am providing the grib2 file for anyone that needs it on Google Drive.
Edit : This is the colorization file needed for testing
Here is my process to convert this data to tiles, and I suspect the problem is with gdalwarp somehow, but I am not sure. EDIT - Based on comments, It now seems gdal_translate is the likely culprit.
- Use gdal_translate to convert the grib2 file to a GeoTiff
gdal_translate -b 1 MRMS_ReflectivityAtLowestAltitude_00.50_20211212-172838.grib2 Output.tif
- Use gdalwarp to reproject the Output.tif to 3857 for Mapbox.
gdalwarp -t_srs EPSG:3857 Output.tif Output-projected.tif
- I use gdaldem to colorize the file (color is different, this is intentional).
gdaldem color-relief -alpha Output-projected.tif colorization_file.txt Output-colorized.tif
- Last, I use gdal2tiles to tile the image for Mapbox.
python gdal2tiles.py --profile=mercator --processes=8 -x --zoom=0-13 Output-colorized.tif outputDir
I have ran gdalinfo on the output from each step in the process so that anyone may see in detail :
- gdalinfo for original GRIB2 file
- gdalinfo for Output.tif (step 1)
- gdalinfo for Output-projected.tif (step 2)
- gdalinfo for Output-colorized.tif (step 3)
As a bonus, if anyone wanted to visually check this exact data location it is located in Florida at -81.42, 28.85. This is in case someone wants to check the data using their own software.
Edit : For clarity, I am using GDAL 3.4.0, released 2021/11/04
With all of the information above, I can only guess at what I am doing wrong. After hours of fiddling with the script I am still pretty clueless. I have an idea that it has to do with gdalwarp because this is the initial point where I had attempted to change the projection. If anyone needs more information, I will gladly edit this post to include it.