I have a large raster and a line.
I want to preserve the values of the pixels that are below the line, and reclassify all other pixels to NO VALUE or 9999, so that only the pixels where the line overlapped are the same.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI have a large raster and a line.
I want to preserve the values of the pixels that are below the line, and reclassify all other pixels to NO VALUE or 9999, so that only the pixels where the line overlapped are the same.
You can create a buffer around the line to convert the line as a polygon (the distance value depends from your raster resolution) and use the resultant layer as a mask to clip your raster (with the algorithm Clip Raster by mask layer) and create a raster that contains only the pixel overlapping the line.
Then, reclassify the original raster changing all the values in 0.
Next step, with the GDAL > Raster Calculator, create a new raster adding to the raster with no value the clipped raster.