I'm trying to extract field boundaries and features from a lot of aerial images of agricultural land - and avoid digitizing these features manually. I've managed to get a crude raster file of the features that I want by manipulating the threshold colour values in GIMP and geocoding the resulting .tif in QGIS.

Farm outline and resulting Raster overlay

The nine broad contour lines are what I want to extract (and clean up a little) but more importantly I want to remove the randomly distributed noise seen in the middle of the fields. After cleaning the image I plan to convert to a vector and clip the existing farm boundary with it.

I am at a loss as to how to process these data?

I have both QGIS 2.8.1 and GRASS 7 available.

  • Sorry this doesn't answer your question, but could I use Gimp to shade/highlight only hedges on a google maps image? Thanks-I have never used GIMP and need to create my own hedgerow layer for use in QGIS – Abigail Jul 20 '15 at 9:52
  • I'm using the Adjust colour balance tool to highlight the contrasts between bare soil and planted fields - needs to be tweaked to display the differences but works well enough. – gareth_t Jul 20 '15 at 10:03

I'm not sure how well this will work without trying on your specific raster, but a few pointers. I assume from your image you used Threshold in GIMP to give you a binary raster (inside field/outside field)

Removing noise

You can use GDAL Sieve to remove the 'salt and pepper' noise - those little holes within the fields.

You can do this from QGIS (Raster > Analysis > Sieve). That should fill any 'holes' (smaller than an area you specify) with the value of the surrounding raster area. If you're lucky and guess the minimum area well, it might also clean up the noise in the gaps between fields too.

Using QGIS to get edges

Depending on how successful that is, and how well you choose the sieve settings, you may be able to convert the noise-free raster straight to polygons. There seems to be a lot of noise in the gaps between fields so there's a good chance you end up with some fields joined together.

Using SAGA to get edges

If you get a reasonably clean noise-free image from Sieve

SAGA GIS has a Raster Connectivty Filter (Grid > Filter > Connectivity Analysis). This will give two outputs

  • a raster, with each contiguous area of pixels given its own ID
  • a shapefile with the boundary of each contiguous area of pixels

Using GIMP to get edges

GIMP has a number of noise-removal and edge filters (e.g. Sobel, Difference of Guassians etc), you might want to try these too.


You might also need to simplify geometries to get rid of the 'staircasing' (the polygon edges will trace round pixel boundaries)


Steven already shared a very good walk-through!
I just want to add that you could also use the QGIS LecoS plugin (requires active numpy/scipy installation within your QGIS path) for this purpose. Especially for raster basic cleaning and edge extraction purposes. LecoS has a so-called landscape modifier since some time, which applies scipy's erosion abilities on raster image arrays.

Extracted Woodland cover from Satellite data before removing small pixels Extracted Woodland cover from Satellite data before removing small pixels
Woodland after removing smaller pixel noise, filling of holes and increase of remainders Woodland after removing smaller pixels

LecoS can iteratively (for instance in a QGIS Processing model) clean small pixels in patches, close holes, increase or decrease all patches by a number of pixels, isolate the single greatest or smallest patch and also extract patch edges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.