I am writing a python API (WMS format) to fetch the gridded weather data(rainfall) and convert it into png images. I am using GDAL for this and involves below steps:
- Fetching data from database using the BBOX from WMS
- Rasterizing the data using gdal.Rasterize and converting the data into tiff files
- Then applying style to the tiff using gdal.DEMProcessing and converting the tiff into png and returning the PNG images as output from the API.
- Consuming this WMS API from openlayers to overlay the data on map.
Problem: The problem I am facing is I am unable to get proper image size of the generated images because of which the data is shown as below in the image. Need help to know what is the correct set of options to be used in rasterize or demprocessing to get correct output. Sample code:
options = gdal.RasterizeOptions(
format='GTiff', attribute='value', noData=NoData_value,
width=w, height=h,
outputType=gdalconst.GDT_Float32,
outputBounds=[x_min,y_min,x_max,y_max],
outputSRS=crs)