When I download DEMs for a diagonal section of coastline, I am forced to download a rectangular area, which leaves gigabytes of unused data. I want to delete the DEM files for the areas I don't need.

After building my map in QGIS, by importing ASC files as raster layers, is there a way to draw a selection, and remove all layers within that selection or another quick way to delete unwanted DEMs/ASC files?

This describes how to select features within a layer for deletion. My goal is to select layers on the map for deletion.

  • The end-goal is to delete the files from the hard drive. Whatever achieves that goal in the fewest steps is the ideal solution. Jan 27, 2022 at 8:22
  • 1
    Easier is to select all you need and delete everything else.
    – Gery
    Feb 13, 2022 at 20:37
  • mmmmm not sure how to do it in QGIS, I would do it programatically in linux using a combination of linux-based tools and GIS tools (e.g., gdal). I would first find a way to filter the ones I need (perhaps you can select them within a region of interest? or filter them by their names?) and then move them to an another directory. This would be my first practical attempt to solve this.
    – Gery
    Feb 15, 2022 at 15:09
  • 1
    Thanks @Gery - someone helped me find a solution today which matches your idea: merge raster files into one layer first, create a polygon shapefile representing the areas you want to keep, then "clip raster by mask layer" using that shapefile. Posted the solution below. Apr 10, 2022 at 7:11

1 Answer 1

  1. Merge all the raster layers. Raster>Miscellaneous>Merge
  2. Draw a polygon shapefile representing the area you wish to keep. Layer>Create Layer>Shapefile (polygon)
  3. Crop the merged raster file using the shapefile as a mask, save permanently. Raster>Extraction>Clip raster by mask layer
  4. Delete original raster files!

Thanks to QGIS Community - Official Virtual Group for helping me find the solution.

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.