4

I am trying to run the following analysis in QGIS 3.2.

My inputs:

  • raster layer (with population estimates from LandScan)
  • vector layer, with points (each point represent the location of a mobile cell tower)

I want to define for every cell of the raster layer (masked for one specific country):

  • it's value
  • it's distance (preferably in meters) to the closest point/cell tower.

The output can be another raster layer or any format that can be exported for further analysis in Excel.

I have tried so far Raster -> Nearest Neighbour, which generates a binary raster map with no values, so I am clearly doing something wrong.

A snapshot of my current setup is below. Blue dots are cell towers, a brown gradient is the raster data.

example

1
  • 1
    This provides a solution when both layers are vectors, so one possible way of doing this could be "vectorizing" my raster layer first, but this doesn't seem elegant nor right. Sep 18, 2018 at 9:40

1 Answer 1

3

I managed to get the results I needed by following these steps:

  • Clipped my population raster layer to reduce processing time and memory requirements (Raster -> Extraction -> Clip Raster by Mask Layer) messes up with the "add raster value" step

  • Created a new dummy point grid vector that covers the target area. I set X,Y min,max manually and the distance was the size of my raster layer cell (Processing -> SAGA -> Vector point tools -> Create point grid)

  • Clipped the dummy point grid to the size of the region of interest (Vector -> Geoprocessing Tools -> Clipping)

  • Translated the vector point grid layer to coincides the points with the raster layer cell center. This was required because X,Y min,max on the previous steps require integers.

  • Added the underlying raster values as features on the point grid vector layer. (Processing -> SAGA -> Vector-Raster -> Add raster values to features)

  • Calculated distances to nearest neighbor, by running Distance Matrix analysis between the dummy point cloud (now with added features) and the vector layer containing the base station data, selecting only the closes neighbor (Vector -> Analysis -> Distance Matrix)

  • Joining the Distance Matrix with the Point Cloud layer to get both the population and the distance to the closest base station

I hope this is useful to other people!

ps: The link on the first comment of the question have more details about the Distance Matrix calculations.

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.