1

I am trying to fetch data from geoserver WMS layer in geojson. When previewing layer everything works fine:

http://79.101.20.137:8080/geoserver/eig/wms?service=WMS&version=1.1.0&request=GetMap&layers=eig%3Atp&bbox=12.612376313105207%2C32.874999390114596%2C35.97501363287868%2C47.634998931418615&width=768&height=485&srs=EPSG%3A4326&styles=&format=application/openlayers

I tried to adjust above link with using this tutorial to get json response:

http://79.101.20.137:8080/geoserver/eig/wms?SERVICE=WMS&VERSION=1.1.0&REQUEST=GetFeatureInfo&FORMAT=application/json&TRANSPARENT=true&QUERY_LAYERS=eig:t2m&LAYERS=eig:t2m&exceptions=application/vnd.ogc.se_inimage&INFO_FORMAT=application/json&FEATURE_COUNT=50&X=50&Y=50&SRS=EPSG:4326&STYLES=&WIDTH=101&HEIGHT=101&BBOX=4.2254877427993645,50.750177078705356,4.4957029774594135,50.921063532317916

but I got empty json response:

{"type":"FeatureCollection","features":[],"totalFeatures":"unknown","numberReturned":0,"timeStamp":"2023-01-15T20:00:24.592Z","crs":null}

I tried with testing with different layers, but no luck so far. Layers are created from raster images and the have time dimension.

0

1 Answer 1

1

The correct URL to get JSON is

http://79.101.20.137:8080/geoserver/eig/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image/jpeg&TRANSPARENT=true&QUERY_LAYERS=eig:tp&STYLES=&LAYERS=eig:tp&exceptions=application/vnd.ogc.se_inimage&INFO_FORMAT=application/json&FEATURE_COUNT=50&X=50&Y=50&SRS=EPSG:4326&WIDTH=101&HEIGHT=101&BBOX=13.58940124511719,44.68002319335938,13.728103637695314,44.81872558593751

It returns

{"type":"FeatureCollection","features":[{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":0.3075000047683716}}],"totalFeatures":"unknown","numberReturned":1,"timeStamp":"2023-01-15T20:33:29.629Z","crs":null}

I used the browser network console, clicked, and just changed the INFO_FORMAT to application/json. All else I copied verbatim from the request the demo GUI sent.

When you sent your request you used FORMAT=application/json, which tries to request the WMS image in application/json. This obviously does not work, although I don't see why a GetFeatureInfo request needs the format parameter anyways, because it's not returning an image...

2
  • 1
    It needs it because dumb clients can just add Info_Format and I and J to the whole request with out any need to parse it and modify it
    – Ian Turton
    Commented Jan 16, 2023 at 8:29
  • 1
    It needs it because the GetFeatureInfo request is stateless. The server doesn't know what map was being looked at when the client clicks on a location. So the info request has to include all the information to create the map, plus extra parameters to specify the response for the information
    – nmtoken
    Commented Jan 16, 2023 at 9:02

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.