I want to create a Square Buffer of 10 km around a .vrt (Raster) file in QGIS using Python programming in QGIS Python Console.
Please help me to write this python program for creating buffer around a .vrt file in QGIS.
What I have tried is that I first convert the input .vrt file (raster) into a .shp file (vector).
processing.runalg("gdalogr:polygonize","E:/Sreeraj/Task Global Data CONVERSION/Split/XYZ to UTM/contour1.vrt","DN","E:/Sreeraj/Task Global Data CONVERSION/Split/XYZ to UTM/shapefile.shp")
And then created a buffer around the .shp file.
processing.runalg("gdalogr:buffervectors","E:/Sreeraj/Task Global Data CONVERSION/Split/XYZ to UTM/shapefile.shp","geometry",10,False,None,False,"","E:/Sreeraj/Task Global Data CONVERSION/Split/XYZ to UTM/buffer.shp")
Then I converted the buffered output .shp file (vector) back to a .vrt file (raster).
processing.runalg("gdalogr:rasterize","E:/Sreeraj/Task Global Data CONVERSION/Split/XYZ to UTM/buffer.shp","ID",0,100,100,"-116.669027778,-116.280972222,34.02625,34.3456944447",False,5,"",4,75,6,1,False,0,"","E:/Sreeraj/Task Global Data CONVERSION/Split/XYZ to UTM/contour2.vrt")
So, I got a buffer (contour2.vrt) output .vrt file around the input (contour1.vrt) .vrt file.
But, I know that this is a really crazy idea. What I am checking is for a python code which will directly create a buffer around a raster in a single step (as we create a buffer around a vector).