WMS GetMap Request – Comprehensive Guide to Efficiently Using GetFeatureInfo and Pixel Retrieval

getfeatureinfoimagepixelwms

I formulate a GetFeatureInfo request that returns the feature information of the centre point of the map. The GetFeatureInfo request for WMS is:

http://geoservices-inspire.irisnet.be/geoserver/cirb_cibg/ows?request=GetFeatureInfo&FORMAT=text/xml&CRS=CRS:84&SRSKEY=CRS&STYLES=&WIDTH=1500&HEIGHT=1500&version=1.3.0&LAYERS=TN.RoadTransportNetwork.RoadArea&PROJECTION=CRS:84&BBOX=4.2254877427993645,50.750177078705356,4.4957029774594135,50.921063532317916&service=WMS&TRANSPARENT=TRUE&query_layers=TN.RoadTransportNetwork.RoadArea&I=750&J=750

enter image description here

Now, I want to ask, does this feature selected can be shown in an image format. I have tried to use the GetMap request (in WMS) for the above I & J values as:-

http://geoservices-inspire.irisnet.be/geoserver/cirb_cibg/ows?request=GetMap%20&FORMAT=image/png&CRS=CRS:84&SRSKEY=CRS&STYLES=&WIDTH=1500&HEIGHT=1500&version=1.3.0&LAYERS=TN.RoadTransportNetwork.RoadArea&PROJECTION=CRS:84&BBOX=4.2254877427993645,50.750177078705356,4.4957029774594135,50.921063532317916&service=WMS&TRANSPARENT=TRUE&query_layers=TN.RoadTransportNetwork.RoadArea&I=750&J=750

The result is as shown in figure:-

GetFeatureInfo response

Doesn't the map display only the map features containing the above I and J value? Can't image be produced using GetMap request for the particular I and J value? Why is this image displaying full?

Best Answer

You can ask that question from the WMS server with GetCapablities.

http://geoservices-inspire.irisnet.be/geoserver/cirb_cibg/ows?service=WMS&version=1.3.0&request=GetCapabilities

The section about GetFeatureInfo request contains the supported formats

<GetFeatureInfo>
<Format>text/plain</Format>
<Format>application/vnd.ogc.gml</Format>
<Format>text/xml</Format>
<Format>application/vnd.ogc.gml/3.1.1</Format>
<Format>text/xml; subtype=gml/3.1.1</Format>
<Format>text/html</Format>
<Format>application/json</Format>

None of these formats is image format. the meaning of the request is to return data about the selected feature and attributes cannot be expressed in image. But you can as the server to send the response back as GeoJSON

http://geoservices-inspire.irisnet.be/geoserver/cirb_cibg/ows?request=GetFeatureInfo%20&FORMAT=text/xml&CRS=CRS:84&SRSKEY=CRS&STYLES=&WIDTH=1500&HEIGHT=1500&version=1.3.0&LAYERS=TN.RoadTransportNetwork.RoadArea&PROJECTION=CRS:84&BBOX=4.2254877427993645,50.750177078705356,4.4957029774594135,50.921063532317916&service=WMS&TRANSPARENT=TRUE&query_layers=TN.RoadTransportNetwork.RoadArea&I=750&J=750&info_format=application/json

The response is

{"type":"FeatureCollection","features":[{"type":"Feature","id":"TN.RoadTransportNetwork.RoadArea.15412","geometry":{"type":"MultiPolygon","coordinates":[[[[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51],[4,51]]]]},"geometry_name":"the_geom","properties":{"gml_id":"BE.BRUSSELS.BRIC.ADM.SS.10208","gml_identi":"http://urbisdownload-v2.gis.irisnet.be/en/temporality#BE.BRUSSELS.BRIC.ADM.SS.10208","gml_descri":"","insp_ns":"http://urbisdownload-v2.gis.irisnet.be/en/temporality#","insp_id":"BE.BRUSSELS.BRIC.ADM.SS.10208","name_fr":"","name_nl":"","spec":"","bbox":[4,51,4,51]}}],"totalFeatures":"unknown","numberReturned":1,"timeStamp":"2022-02-04T09:19:05.945Z","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::4326"}},"bbox":[4,51,4,51]}

Now you could make your application to parse the GeoJSON and render the geometry on the map. But unfortunately the geometry that the server sends is nonsense, a multipolygon with all vertices at coordinates (4,51). I guess that is because the service provider does not want to send accurate geometries with GetFeatureInfo requests.

Related Question