0

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:

  1. Fetching data from database using the BBOX from WMS
  2. Rasterizing the data using gdal.Rasterize and converting the data into tiff files
  3. 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.
  4. 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)

WMS Image on map

Prashant
  • 55
  • 1
  • 9
  • why not just request PNG tiles from GeoServer? – Ian Turton Dec 26 '21 at 11:51
  • @IanTurton, As mentioned, it is custom API of WMS specification – Prashant Dec 26 '21 at 13:50
  • 1
    Very strange way of doing it, why do you need to rasterize and use DEM? Why don't you simply directly create a raster GeoTIFF with the data coming from the database? – mmomtchev Jan 10 '22 at 01:18
  • @mmomtchev, how to convert precipitation data directly into coloured GeoTiff, can you provide any sample code? – Prashant Jan 11 '22 at 12:24
  • What form does have your original data? rows and columns with floating point numbers? – mmomtchev Jan 11 '22 at 12:29
  • lat, long with floating point numbers fetched as a dataframe --> saved as csv,vrt --> rasterized to tiff --> applied color map using demprocessing --> converted to PNG using translate – Prashant Jan 12 '22 at 11:48

0 Answers0