如何按属性值过滤WMS服务中的数据?——筛选Fire Status非'Out'点位的方法咨询
Great question! While SLD is a valid way to style and filter features, there's a far simpler approach for basic attribute filtering: using the CQL_FILTER parameter directly in your WMS GetMap request. This lets you skip writing a full SLD document and apply filters in a concise, SQL-like syntax.
How to Implement the Filter
Your goal is to exclude all points where the Fire Status attribute equals 'Out'. Here's how to structure your WMS request with the filter:
https://openmaps.gov.bc.ca/geo/pub/WHSE_LAND_AND_NATURAL_RESOURCE.PROT_CURRENT_FIRE_PNTS_SP/ows? SERVICE=WMS& REQUEST=GetMap& VERSION=1.3.0& LAYERS=WHSE_LAND_AND_NATURAL_RESOURCE.PROT_CURRENT_FIRE_PNTS_SP& CRS=EPSG:4326& BBOX=-126,48,-114,60& WIDTH=800& HEIGHT=600& FORMAT=image/png& CQL_FILTER="Fire Status" <> 'Out'
Key Details:
CQL_FILTER="Fire Status" <> 'Out': This clause filters features where theFire Statusattribute is not equal to 'Out'. Note the double quotes around the attribute name (since it contains a space) and single quotes around the string value 'Out'.- Most modern WMS servers (like GeoServer, MapServer, and the BC Open Maps service you're using) support
CQL_FILTERas part of the OGC Common Query Language standard.
Alternative: Filter Encoding (If CQL Isn't Supported)
If for some reason CQL_FILTER isn't enabled on the service, you can use the FILTER parameter with OGC Filter Encoding XML syntax, though this is more verbose:
<Filter> <PropertyIsNotEqualTo> <PropertyName>Fire Status</PropertyName> <Literal>Out</Literal> </PropertyIsNotEqualTo> </Filter>
You'd include this XML as the value of the FILTER parameter in your GetMap request (url-encoded, of course), but CQL_FILTER is almost always the cleaner choice for simple filters like this.
Just test the CQL example above—your BC WMS service should handle it smoothly, returning only the fire points that aren't marked as 'Out'.
内容的提问来源于stack exchange,提问作者gecco15

