I have a raster image that looks like this (see below)

How do I remove the outlying islands and keep only the central main island in the image. Is it a geoprocessing clip function? I am using QGIS 2.8.1, I added a .tif file from a downloaded DEM and then used the raster>analysis>DEM(terrain models)

  • Please edit the question to specify the format of the raster (it can't possibly be shapefile, because that's a vector format).
    – Vince
    May 13, 2015 at 4:02
  • 1
    Do you have a shapefile for the region that you want to keep? If not, then you'll have to create one. May 13, 2015 at 4:36
  • If you're using ArcMap please include if you have access to Spatial Analyst; this could be done without it using QGIS but there's a few more steps. As @DevdattaTengshe indicated you must have a polygon feature class (shapefile will do) indicating the area you want to 'keep' regardless of the software you will be using to do this. May 13, 2015 at 4:44
  • Very closely related: gis.stackexchange.com/questions/13090. BTW, @Devdatta, that thread (as well as my answer here) demonstrate that no shapefiles need to be created at all.
    – whuber
    May 14, 2015 at 14:22

3 Answers 3


For raster processing, "clip" usually refers to the extraction of rectangular subset. So you are looking for "mask" which extract a region of interest. This post will show you a simple way to mask a raster in QGIS (using raster calculator), but most of the time I prefer masking "on the fly" with the mask plugin. In any case, you'll need a layer with the extent of your region of interest in order to proceed. If you don't, drawing it manually should not take you too long.

  • Thanks for your help, managed to get there in the end, Cheers May 13, 2015 at 23:26

An accurate and relatively automatic way to perform this (commonly needed operation) is to

  1. Preprocess the image into a single-band raster. The purpose is to identify clear boundaries to the islands, which in a multi-band image may just taper off into a set of colors (such as the grays in the example). The could be done by separating the image into bands, thresholding each band (with a map calculation), and overlaying the bands again.

  2. "Region group" or "clump" the raster. This creates a categorical raster with one distinct identifier for each contiguous region identified.

  3. Identify the largest region: it will be the one with the greatest area (or cell count). Use this identifier to create a mask.

If desired, apply the mask to the original image to eliminate all the outlying islands.

Worked examples of this procedure appear on this site at https://gis.stackexchange.com/a/33831, https://gis.stackexchange.com/a/79334, https://gis.stackexchange.com/a/76231 (which illustrates the use of morphological operations in the initial cleaning step), https://gis.stackexchange.com/a/28466 (ditto), and especially Filtering a raster by pixel cluster size in ArcGIS?, which is almost exactly the same question, but with a focus on removing the smallest islands rather than retaining the largest.


As an alternative approach, you could convert the raster to a polygon, then edit the polygon to remove the un-wanted regions/islands. Then, you could use this new polygon as a mask.

Raster to polygon: Convert the raster to polygon with the raster to polygon tool.
Uncheck the 'simplify polygons' option so that the polygon edges in the output conform to exact raster cell edges.

Edit polygon: Then open the editor tool and the attribute table of the new polygon. Use the select tool to identify the islands/regions that you don't want to keep, and delete them from the attribute table. You can quickly identify the areas you don't want in the attribute table by first identifying the areas that you do want.

Extract by mask: Now that you have a masking layer, use the extract by ask to remove that raster cells from your analysis.

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.