I would like to create a distance map using OpenStreetMap objects as input objects. To explain what I mean with distance map, let's look at the wikipedia definition:

A distance transform, also known as distance map or distance field, is a derived representation of a digital image. [...] The map labels each pixel of the image with the distance to the nearest obstacle pixel.

Imagine, for example, one wants to create a distance map for Sweden, indicating the distance for each pixel to the nearest alcohol takeway (OSM key: shop, OSM value: alcohol). This would require the following steps:

  1. Gather all OSM data for the area inside the country borders of Sweden

  2. Define pixel spacing of desired raster map (e.g. 1m or 1 km etc.)

  3. Calculate distance for every pixel of that map to nearest alcohol shop OSM map feature using a to-be-defined distance metric (e.g. Euclidian distance)

While I have a clear conceptual idea of how to do it, I don't know where to start implementation-wise.

Is there a good Python API that allows to do such a thing without too much overhead?

Or is it easier to achieve my goal in QGIS?

  • 1
    I am guessing you will have to use PostGIS and pgrouting. This post might get you started. – LMB Jul 23 '19 at 13:06
  • 1
    GDAL has the Proximity (raster distance) algorithm that might be what you're asking for. You can use it in QGIS. – csk Jul 23 '19 at 15:00

Your Answer

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

Browse other questions tagged or ask your own question.