4

I am preparing a set of environmental variables and I am fairly new to QGIS.

I am in possession of a land cover raster layer (downloaded from Copernicus) which I have reclassified for my study area into forest (green) and non-forest (black) - see picture below.

I would like to derive a raster layer for my study area that expresses for each cell the distance (in meters) to the nearest forest edge; raster grid cells outside and inside forest polygons should be associated with positive and negative distance values, respectively.

How can this be done in QGIS? Do I have first to convert the raster into a vector, or can I use the raster directly?

enter image description here

2
  • 1
    Have you done a search? This is a very similar question, except you'd need to convert your forest raster to a "forest edge" raster: gis.stackexchange.com/questions/268939/… May 5, 2023 at 12:41
  • Yes I've searched this morning, anyway thanks for the link, I can see it now!
    – Danny
    May 5, 2023 at 13:23

1 Answer 1

4

you can you the proximity tool (Raster > analysis > proximity), which comes from gdal_proximity if you need more details.

The proximity tools uses a raster input, so there is no need to convert your result into polygon. However, make sure that you set the value of the non forest pixels to zero OR to define the value of your forest class as the target.

3
  • 1
    Hi, thank you very much for your reply! I know the Proximity tool from GDAL, the problem is that it does not calculate the distance inside forest cells, but only outside it...
    – Danny
    May 5, 2023 at 13:20
  • @Danny - just do a second proximity calculation in which the target is the non-forest cells and find the distance of forest cells from the boundary of non-forest cells. Then combine the layers using the raster calculator
    – Llaves
    May 6, 2023 at 3:49
  • @Llaves thank you very much for your reply! I think it should work actually, I'll try it and let you know
    – Danny
    May 6, 2023 at 6:01

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.