[GIS] Controlling output linewidth linestyle using gdal_rasterize shapefile shp to Geotiff

gdalshapefile

I have successfully combined a shapefile (.shp) and a GeoTiff using gdal_rasterize.

The shapefile displays as one pixel wide in the GeoTiff, but I need it to be wider and more visible, say, 5 pixels wide and red.

Can anyone suggest an alternate way to achieve this? This needs to run as a script and not use desktop gis software.

Best Answer

You can calculate a buffer directly with ogr2ogr using GDAL >= 1.10 with SQLite and SpatiaLite support. If the raster spatial resolution is e.g. 1m:

ogr2ogr -dialect SQLite -sql "SELECT ST_Buffer(geometry,2.5) FROM lines" buffer_lines.shp lines.shp

Finally, you can adapt and apply the first example of gdal_rasterize documentation:

gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l buffer_lines buffer_lines.shp work.tif