I have a polygon shapefile that is bigger in extent than my DEM.

I want to clip my raster dem to my shapefile and fill missing space with NoData.

I have tried clip raster by mask layer as well as by extent, translate and export > save as, but none of this is working.

How can I make my dem the same size as my shapefile and fill missing space with NoData or 0?

1 Answer 1


You can use "Create constant raster" from the processing toolbox to create an empty raster with the extents of your shapefile and the cell size of the DEM and a constant value of 0. Then use the raster calculator to create an addition formula to add the pixel value of the DEM to that of the larger raster.

You should end up with a raster image with the DEM values and a 0 outside the extent of the DEM. One issue though is if your original DEM has 0 elevation values it will be difficult to replace the 0 in the large raster with No Data.

Will try to update this answer once I'm in front of my PC.

  • I tried this and it seems to work although my higher elevation values changed from 3772 to 3829. do you know why is that? it's not actually important cause i'm just doing it for visualization and not for analysis but would like to know why my high elevation values changed
    – Adi
    Commented Jul 22, 2021 at 14:16
  • How did you check the highest elevation value?
    – Techie_Gus
    Commented Jul 22, 2021 at 14:18
  • I can see it in my ramp values, min and max
    – Adi
    Commented Jul 22, 2021 at 14:21
  • You may need to recompute the statistics. I don't see a reason why a cell value would change. Try to inspect individual cell values in the original and final output raster to make sure no value change occured.
    – Techie_Gus
    Commented Jul 22, 2021 at 14:24

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.