[docs]defsaveraster(gdal_data,filename,raster):''' Unchanged function to save raster data to a GeoTIFF file, using another opened in GDAL .TIFF file as basis. Input: gdal_data (gdal.Open): Basis gdal dataset filename (str): filename to save to raster (np.ndarray): raster array '''rows=gdal_data.RasterYSizecols=gdal_data.RasterXSizeoutDs=gdal.GetDriverByName("GTiff").Create(filename,cols,rows,int(1),GDT_Float32)outBand=outDs.GetRasterBand(1)# write the dataoutBand.SetNoDataValue(-9999)outBand.WriteArray(raster,0,0)# flush data to disk, set the NoData value and calculate statsoutBand.FlushCache()# georeference the image and set the projectionoutDs.SetGeoTransform(gdal_data.GetGeoTransform())outDs.SetProjection(gdal_data.GetProjection())