I'm trying to follow the set of instructions here: https://twitter.com/imhere_asia/status/1023055838787690496

[EDIT] Pasting the instructions here for reference so people can avoid twitter.

  1. Add a DEM raster into your project
  2. Open the processing panel, and select the "Create grid" algorithm
  3. You'll want to create a point grid, with narrow horizontal spacing (roughly matching the cell size of you DEM raster) and larger vertical spacing)
  4. Select the "Translate" algorithm
  5. Use the above-created point grid as your input layer
  6. The magic happens here: set the y-axis offset distance value to be the following data-defined expression: "raster_value('dem_layer',1,$geometry)
  7. Run the algorithm
  8. Lastly, select the "Points to path" algorithm
  9. Use the above-created translated layer as input layer
  10. Use the "left" field as order field and "top" field as group field
  11. Run the algorithm, et voila.

enter image description here

The end goal of this is to end up with a map corresponding to the DEM that looks sort of like the classic joy division cover (see image above from twitter). The spot where I'm getting stuck is step 6.


However, when I translate the grid by raster_value('my_dem',1,$geometry), the algorithm runs, but the new layer is identical. The dem layer is an SRTM GeoTIFF. What am I doing wrong?

  • Both raster and vector layer have the same CRS? Commented Feb 17, 2019 at 0:13
  • Please Edit the question to post the relevant instruction in the body of the question. Forcing folks to look things up in third-pary sites is not a reliable way to get your question answered.
    – Vince
    Commented Feb 17, 2019 at 0:27
  • Yes, I believe that both have the same CRS.
    – Paul Wicks
    Commented Feb 17, 2019 at 3:26

1 Answer 1


If the ouput layer of the Translate tool is identical to the input layer, the offset distance must to be zero (or null).
Therefore, the output of the raster_value() function must to be zero or null.

From the help of the raster_value() function in the expression string builder:

Returns the raster value found at the provided point.
layer: the name or id of a raster layer
band: the band number to sample the value from.
point: point geometry (for multipart geometries having more than one part, a null value will be returned).

There are one way for the function to return zero and (at least) one way to return null:

  • The pixel value, at the provided position, is zero.
    It is strange in a DEM, even unsense, providing rows of positions that cover its extent.

  • The position of the point is not a position in the raster.
    This is the more common issue in this kind of functions, in which is referred to the position of a layer from the position of a geometry in a different layer.

For instance, if a point point has coordinates (35, 68) in its CRS, but the extent of the raster layer is around coordinates (1385960, 85574326) in its own CRS, and it is totally possible that both coordinate pairs represent the same position in the Earth, each one in its CRS (and also QGIS can render on-the-fly both layers one over the other), then the function try to extract the pixel value of the raster in (35, 68), finds nothing and returns null.

Therefore, check the properties of each layer and observe its CRS, if they are different, reproject the points layer to the same CRS of the raster layer (or create a new grid of points in that CRS), and perform the translate in the new layer.

  • Thanks for the help! I managed to get it working, I think somehow things had gotten into differing CRS's, although I'm not quite sure how.
    – Paul Wicks
    Commented Feb 17, 2019 at 6:57
  • You are welcome. I'm glad it worked. I made some edits to my answer. After testing the case of trying to pass the wrong layer or band name, the expression returns an error and does not allow it to be inserted. Commented Feb 17, 2019 at 11:46

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.