You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何按属性值过滤WMS服务中的数据?——筛选Fire Status非'Out'点位的方法咨询

Filtering WMS Features Without SLD: Using CQL_FILTER

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 the Fire Status attribute 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_FILTER as 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 18:57:34