[GIS] Highlight a feature in a WMS map image

geoserverstylewms

For the following request, how would I produce a single PNG image highlighting just one feature? For example GMUID=84

Here is the base map image

https://maps.huntscore.com/geoserver/colorado/wms?service=WMS&version=1.1.0&request=GetMap&layers=colorado:BigGameGMUBoundaries12092014&styles=MiniMap_Outlines&bbox=139992.54690000042,4094064.75,763240.4375,4546735.0&width=768&height=557&srs=EPSG:26913&format=image%2Fpng

Here is the highlighted feature

http://maps.huntscore.com:8080/geoserver/colorado/wms?service=WMS&version=1.1.0&request=GetMap&layers=colorado:BigGameGMUBoundaries12092014&CQL_FILTER=GMUID=84&styles=MiniMap_Polygon&bbox=139992.54690000042,4094064.75,763240.4375,4546735.0&width=768&height=557&srs=EPSG:26913&format=image%2Fpng

Best Answer

There is a WFS service available, too, which allows you to access the underlying data that you see in the WMS response. You can browse all of these here in the Geoserver interface: https://maps.huntscore.com/geoserver/web/?wicket:bookmarkablePage=:org.geoserver.web.demo.MapPreviewPage

Then you can make a request just for the feature you want, which is well covered by this question's answers: Passing Filter Parameters to GeoServer WFS via URL?

The query you want is something like this (this one returns GeoJSON): https://maps.huntscore.com/geoserver/ows?service=wfs&version=1.0.0&request=getfeature&typename=colorado:BigGameGMUBoundaries12092014&CQL_FILTER=GMUID=84&outputFormat=application/json

You will need to apply your own styling once you have the features you are after. Perhaps the best thing to do is to continue requesting the WMS image as you are already doing, but also overlay the result of the WFS request on top in the client, and style that as you see fit.

EDIT: to stay within WMS, what you want to do is specify multiple layers (well, the same layer twice), and apply two filters, and two styles:

http://maps.huntscore.com:8080/geoserver/colorado/wms?service=WMS&version=1.1.0&request=GetMap&layers=colorado:BigGameGMUBoundaries12092014,BigGameGMUBoundaries12092014&cql_filter=GMUID%3E0;GMUID=84&styles=MiniMap_Outlines,MiniMap_Polygon&bbox=139992.54690000042,4094064.75,763240.4375,4546735.0&width=768&height=557&srs=EPSG:26913&format=image%2Fpng

enter image description here

Related Question