I'm interested to know what sort of software and/or concepts should I learn to be be able to get a computer to recognize desert roads in a satellite image and measure for example their average widths. This satellite is an example of what sort of images I intend to use.

enter image description here

I'm relatively fluent in python (to the extent of object oriented programming and django web development) and have used python to do basic machine learning tasks. I also am familiar with QGIS. I have no idea if the goal I am trying to achieve will require knowledge within these two skills and so that is why I need some guidance on what sort of direction I would have to go to achieve this if this is even possible yet (I have no idea whether it is or isn't).

If you think this question belongs in another site of stack exchange, please redirect me to where as I understand this can be quite a general question involving both geography and possibly machine learning.

edit: assuming you know the scale of the image.

  • 4
    $\begingroup$ I love these questions. I'd never think of a problem of width of desert roads if not for this post $\endgroup$
    – Aksakal
    Jun 26, 2020 at 16:08
  • 1
    $\begingroup$ Can you assume that you're given the scale of the satellite image? $\endgroup$
    – C8H10N4O2
    Jul 1, 2020 at 19:59
  • 1
    $\begingroup$ yes, sorry that I didn't mention it $\endgroup$
    – Ark Lomas
    Jul 1, 2020 at 21:02
  • 2
    $\begingroup$ A standard image processing line detection process will identify the likely roads and then the usual morphological operators of erosion and dilation, followed by a distance calculation, is one way this problem is frequently solved. $\endgroup$
    – whuber
    Jul 3, 2020 at 14:41

1 Answer 1


One approach that comes to mind is to segment the image into "road" and "not-road" (a nice introduction is given e.g. in lecture 7 of the fastai Deep Learning for coders course - a lot can also be found in relevant Kaggle competitions).

Note that the fastai library or its version 2 fastaiv2 (associated with the aforementioned fastai course) are great to get started quickly, and very nicely cover vanilla image segmentation out-of-the-box. If you like their style of coding, you can dive into it and learn how to adapt it as needed. Of course, you can instead use other DL libraries such as keras, for which you find nice example notebooks in relevant Kaggle competitions (search for kaggle competition satellite image segmentation for more relevant material).

The training data would be a pixel-by-pixel annotation of a reasonable number of training images (you obviously would not annotate on a pixel-by-pixel basis, but rather by drawing lines/outlines and specifying that what's between two lines is a road and what's outside is not). The annotation is obviously rather tedious, unless you find segmented satellite pixture somewhere (great if someone else has already done the work! In particular, it can be hugely helpful if the existing dataset is much bigger than anything you'd need. E.g. perhaps some dataset from Kaggle or some other source - depending on whether works okay for desert images, as well as whether it is under a suitable license etc.).

Then you train some suitable machine learning model (e.g. a U-Net starting from a pre-trained ResNet) to predict this for new images. Either the library you use already does image augementation for you or you need to do it yourself (e.g. in a satellite picture the road could be going in any direction, so rotating the image is a plausible augmentation, or slightly different colors etc.). You can probably more or less follow the basic recipe for image segmentation without much modification.

Once you have a trained model for segmenting new unseen images and have done the prediction for the new images, you just need to figure out how wide the road is. If there's just one road in an image, you might just be able to put some kind of LOESS or similar curve through the pixels labelles as road and then count pixels to both sides perpendicular to the local LOESS curve (afterwards, you average the width in pixels along the road - or for a certain length of road segment if the widht can vary along the road - and convert that to e.g. meters based on what you know of the resolution of your image). Alternatively (and this should work even if there's multiple roads), you could for each pixel labelled as road calculate the shortest distance in pixels (going in both directions at once) until you reach non-road pixels on both sides. Afterwards, you perhaps smooth that across surrounding pixels (e.g. using some sensible smoothing kernel, e.g. bivariate-normal, bivariate-Epanechnikov, etc. - bandwidth should probably be wider than the road is wide, possible several multiples). That way you can get for each bit of road how wide the road is around there.

This last step could probably just be done with the matrices/tensors that come out as model predictions and in basic (numpy or similar libraries). Perhaps there is some package that specializes in this, but I do not happen to be aware of it.


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.