I am writing a standalone processing algorithm with pyqgis. The intention of the script is to create an offline basemap that is created only within the extents of objects of one layer. Therefore I am using the native:rasterize tool in a for loop to create the list rasters of temporary rasters. This list is eventually used in gdal:merge to be merged together to one raster. The script runs smoothly until the final step of loading the final raster back to the QGIS project or save it.