After I put together the tutorial below, I discovered the tool
Convert map to raster, which sounds like it does exactly what you want in one step. Description: "This algorithm rasterizes map canvas content." It didn't giving me exactly the output I expected, but I didn't spend very long testing it. Give it a try, it may do exactly what you want in a lot fewer steps. If not, see below:
How to rasterize polygon outlines
- Decide how wide you want the outlines to be, in the unit of measure used by the shapefile. (You can find this information in the shapefile properties under coordinate reference system or CRS.)
In my example, the CRS of my shapefile is EPSG:4326, so its units are decimal degrees. I decided to make my borders 0.02 degrees wide.
- Make a buffer of the shapefile. The buffer distance is half of the negative of the value you chose in the last step. Choose round, mitered or beveled joins depending on how you want the corners to look.
My buffer distance is -0.01. I used round joins.
- Run the Difference tool to subtract the buffered layer from the original polygon layer.
input layer: polygons
difference layer: buffered
Note: the external border is only half as wide as the external border. To fix this, buffer the original polygon with a positive buffer distance (same size as the first buffer), and choose the option to "dissolve result." Subtract the first buffered layer from the second buffered layer, and proceed with step 4.
- Dissolve the difference layer
Rasterize the dissolved layer
use the tool
set style for raster layer