In QGIS 3.14 I try to get elevation data from denmarks elevation model using "kortforsyrningen" plugin. The elevation model (layer name = 'DHM/Terræn') is added as a raster layer (QgsRasterLayer with qgis._core.QgsSingleBandColorDataRenderer)

I use this code (copied from here) to extract elevation at a point in Denmark:

from qgis.core import QgsProject
dhmLayer = QgsProject.instance().mapLayersByName('DHM/Terræn')[0]
x = 724501
y = 6175727
val, res = dhmLayer.dataProvider().sample(QgsPointXY(x, y), 0)

but all I get is val == nan and res == False.

I also tested the other way:

ident = dhmLayer.dataProvider().identify(QgsPointXY(x, y), QgsRaster.IdentifyFormatValue)

With similar results (ident.result() == {}). ident.error() yields

<QgsError: WMS provider Format not supported>

Does anyone have any hint to how to solve this?

  • Does val, res = dhmLayer.dataProvider().sample(QgsPointXY(x, y), 1) return something? Commented Oct 22, 2020 at 12:25
  • only (val, res) = (nan, False) Commented Oct 22, 2020 at 13:40

1 Answer 1


QGIS methods that comment sample and identify query data from images stored on physical or network.

Is it possible to iterate over all pixels in a raster layer from a WMS service ?

Certainly it should be possible

This question was answered here, you will see an option Reading data from raster layer obtained via WMS in QGIS

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.