Q:

Rasterize shapefile to raster based on a raster

I'm wondering if it's possible to rasterize a shapefile based on raster cells as shown below.
I've tried several algorithms on qGIS, but they haven't the option to create a raster based on another raster.

A:

(1) Use SAGA Profiles from lines tool (Processing Toolbox | SAGA | Terraiin Analysis - Profiles) which returns a layer of points located at every cell center which intersects with your input line. Its attribute table has x, y, z along with distance information.
(2) Rasterize the above point layer using z as the cell value.  

