3

I have a WMS layer in QGIS. I am using the Identify Features tool to perform a GetFeatureInfo request. It retrieves the expected attribute data in the Identify Results panel. However I would like to see the URL of the request too. How can I achieve that?

2
7

Simple

Right click your feature in your "Identify Results" right pane and select "Copy GetFeatureInfo requests URL":

Screenshot

Advanced

You can also go with PyQGIS.

For example, with a single layer loaded from a WMS, in the Python console:

layer = iface.activeLayer()
provider = layer.dataProvider()
provider.dataSourceUri()

This will normally show the URI of the data source provider for your layer.

If you want to have access to more information, I can suggest your to have a look both here at the documentation for the qgis.core.QgsRasterDataProvider instance and here.

You can especially try to use the identify method which is probably the one used by the GUI:
https://qgis.org/pyqgis/3.2/core/Raster/QgsRasterDataProvider.html#qgis.core.QgsRasterDataProvider.identify

And which help says:

identify(...) method of qgis._core.QgsRasterDataProvider instance
    identify(self, point: QgsPointXY, format: QgsRaster.IdentifyFormat,
             boundingBox: QgsRectangle = QgsRectangle(), width: int = 0,
             height: int = 0, dpi: int = 96) -> QgsRasterIdentifyResult
    Identify raster value(s) found on the point position. The context
    parameters extent, width and height are important to identify
    on the same zoom level as a displayed map and to do effective
    caching (WCS). If context params are not specified the highest
    resolution is used. capabilities() may be used to test if format
    is supported by provider. Values are set to 'no data' or empty string
    if point is outside data source extent.

Beware of the CRS of your WMS layer if you use that.

But in my case, as the link to the other question also explain, I end up with an empty list:

>>> P = QgsPointXY(783093, 5995473)
>>> rect = QgsRectangle(2696385,4098767,2696402,4098786)
>>> feat = ident.identify(P, QgsRaster.IdentifyFormatValue, 
                          boundingBox=rect, height=2, width=2)
>>> feat.results()
{}

Note

I'm using QGIS 3.12.2-București
with Python '3.6.9 (default, Apr 18 2020, 01:56:04) \n[GCC 8.4.0]'

4

A nice way to see all remote requests such as GetFeatureInfo is to use the "QGIS Network Logger" plugin: https://plugins.qgis.org/plugins/qgisnetworklogger/ which is available since QGIS 3.6

enter image description here

You can then leave the logger window open and add your WMS layer, query it etc, and see the exact urls generated. You can also right-click on the url and have it open in a new browser tab.

enter image description here

There is also an alternative method to see all requests, through software named 'Fiddler', but I recommend the above logger method instead. (more about the alternative Fiddler way at https://github.com/mapserver/mapserver/wiki/Get-the-Raw-WMS-Request-Generated-by-QGIS )

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.