I am trying to convert a vector file that includes polygons to an RGB raster using gdal_rasterize without filling the polygons. Is there a way to do this?

For example, I use the following command to create an RGB raster with opaque black values showing the vector information from a vector file:

gdal_rasterize.exe -burn 0 -burn 0 -burn 0 -burn 255 -ot Byte -ts 927 583 -te -87.7595200000000 41.8042200000000 -87.5067400000000 41.9631900000000 -of GTiff -l ACHARE -l BCNLAT -l BCNSPP -l BERTHS -l BRIDGE -l BUISGL -l BUAARE -l BOYLAT -l BOYSPP -l CBLARE -l CBLOHD -l CBLSUB -l CTNARE US5IL11M.000 out.tif

When I run the above command, I end up with an RGBA raster with a single black box covering most of the image because the vector file has a polygon bounding all the other layers. Is there a way to rasterize only the boundary of this polygon instead of all the area inside this polygon? Is there another tool (preferably with GDAL) I could use to do this?

I might be able to get all the point and line layers in my vector file and only display these layers. This is one possible solution for me if there's not an easy way to do this using gdal_rasterize. I might also be able to convert the polygons to lines and rasterize them as lines. That's another possibility. Both of these solutions would be more work than I was hoping to do to solve this problem.

  • you can try to duplicate your vector layer, remove the boundary polygon and run gdal_rasterize again.
    – Vale
    Jan 11, 2019 at 9:09

1 Answer 1


I didn't find an easy way to do what I needed to do with gdal_rasterize without modifying the gdal_rasterize code and rebuilding it, so here's what I ended up doing as suggested in the last paragraph above. It's a little convoluted, but it suits my needs. I made a temporary shapefile containing all the polygons in the original file stored as polylines and then just converted the point/line layers to one raster file, then the shapefile to another raster file, and then merged the rasters using gdalwarp. I don't have access to python (gdal_merge.py for example) in my framework, so I'm stuck using the .exe's such as gdalwarp, etc. So here's an example of the commands I use to do what I need:

REM -- Convert the vector file to an RGB GeoTIFF.

gdal_rasterize.exe -burn 0 -burn 0 -burn 0 -burn 255 -ot Byte -ts 927 583 -te -87.7595200000000 41.8042200000000 -87.5067400000000 41.9631900000000 -of GTiff -l BCNLAT -l BCNSPP -l BOYLAT -l BOYSPP -l DAYMAR -l FOGSIG -l LIGHTS -l PILPNT -l SOUNDG -l UWTROC US5IL11M.000 noPolyRaster.tif

REM -- Convert the polygon vector file to an RGB GeoTIFF.

gdal_rasterize.exe -burn 0 -burn 0 -burn 0 -burn 255 -ot Byte -ts 927 583 -te -87.7595200000000 41.8042200000000 -87.5067400000000 41.9631900000000 -of GTiff -l polygons polygons.shp polylines.tif

REM -- Merge the two images together into a final display image.

gdalwarp.exe noPolyRaster.tif polylines.tif final.tif

Maybe this will help somebody.

  • is it possible to render shapefiles of different geometries into RGB raster maps using gdal_rasterize? I have lines and polygons shapefiles and I want to create tiff files, displaying polygons in blue and lines in white color with other values as black (background).
    – FJ_Abbasi
    Apr 22, 2019 at 13:48
  • @FJ_Abbasi - the only way I can think of to do this is to burn the polygons as one gdal_rasterize command then then burn the polylines as a separate gdal_rasterize command and then merge the two images into a single image after these operations. You would need the background color to be transparent and then merge the images with a black background color after the two gdal_rasterize commands. I think there's probably a way to set the background color to transparent for each of these output images but I can't think of how to do this off the top of my head (maybe use gdal_translate?)
    – Burrow
    Apr 23, 2019 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.