1

I have a layer on geoserver and I want to get JSON result of a single river. For example get river id=2541.

I see examples that using BBOX. But I do not use BBOX on my wms query.

http://geoserveraddres:8080/geoserver/MFG/wms?REQUEST=GetFeatureInfo&SERVICE=WMS&INFO_FORMAT=application/json&QUERY_LAYERS=MFG%3Ariver

How can I get by id?

1 Answer 1

4

WMS isn't for this. WMS returns a map image, and won't provide you with the JSON you desire.

What you want is WFS (Web Feature Service) which allows you to request and receive the raw data hosted by the service, including in JSON format.

From this document - http://docs.geoserver.org/stable/en/user/services/wfs/reference.html - you'd want something like:

http://example.com/geoserver/wfs? service=wfs& version=2.0.0& request=GetFeature& typeNames=namespace:featuretype& featureID=feature

Although the "featureID" is the GeoServer specific ID I believe and may not be the same as your river_id.

You'd also want to add &outputFormat=application/json to get JSON - http://docs.geoserver.org/stable/en/user/services/wfs/outputformats.html

If you want a more complicated search (i.e., one for a specific river_id), I believe you're going to need to use an XML POST request rather than a URL GET request, or maybe CQL - http://docs.geoserver.org/2.1.3/user/services/wfs/vendor.html.

There are also some examples within GeoServer itself - Demo's -> Demo requests -> WFS*

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.