I am working on a plugin for Qgis to calculate spatial Kernel density maps. I have all the calculations working, all I am missing is a way to turn a Numpy Array, with density values into a multiband raster layer.
Do I have to create a geotiff on a temp file using Gdal and then load it?
Or is there a direct way to create the layer from data in memory?
if so, how to do it?
Best Answer
Here is the code that I use to convert an array to gdal raster saving it to the disk, "param" is a dicitionary containing gdal parameters (check the gdal documentation) and "array" is a numpy array. Than you can instantiate a QgsMapLayer with your file as source. You have to create the geotiff in the disk.