I have an ArcGIS 10 Server with various map services running both the REST API and WMS servers. In the REST API I can call the layerDefs argument to filter features used by one of their properties (e.g. area > 50000).

How do I do this with a WMS call?


For any WMS service (ESRI, MapServer, GeoServer etc.) you should be able to pass in a SLD (Styled Layer Descriptor) file/code to tell the server how to symbolise your data, and which features to return. SLD is written using XML and can be sent directly via a URL, or you can pass in the URL to the SLD file.

There is documentation on the ESRI site - look at the examples in the "Using external SLDs from the client side" section.

Also have a look through the SLD examples for how to filter the data. You'll likely need the polygon_propertyIsEqualTo filter or similar.

  • @geographika I haven't seen this before, very good. – Hairy May 11 '11 at 12:33
  • Yes, SLD does look like the sort of thing I need. Is there a way to just apply the filter without having to restyle the matched polygons? It doesn't appear to work otherwise, and I'd rather not reduplicate a complex style set I have on these services. – PaulNBN May 11 '11 at 12:39
  • @PaulNBN - you should be able to add a filter to an existing rule on the server. However I'm not sure if this requires you to have symbology stored in a server-side SLD to start with. – geographika May 11 '11 at 12:51
  • @Hairy Yes, it's a very nice way to restyle maps from other sources without having to rely in vector data – geographika May 11 '11 at 12:53
  • @geographika It isn't in ArcGIS. – PaulNBN May 11 '11 at 13:01

This may be apparent

As far as I know, a WMS service can only get an image back, not features (no geometry, just the image). Without the images, you can't, obviously query it. So you cna set the layers you want to see, and then a bounding box, but not query the individual layers.

What you require is a WFS service which allows feature access; the following is cut and pasted from Esri:

Serving your data through a WFS service allows any application that can work with Web services to access geographic features from your map or geodatabase. Unlike the OGC Web Map Service (WMS) that returns an image of a map, the WFS service returns actual features with geometry and attributes that clients can use in any type of geospatial analysis. WFS services also support filters that allow users to perform spatial and attribute queries on the data.

ESRI WFS Services

Just got hold of a filter example with WFS:

  <?xml version="1.0" encoding="UTF-8" ?> 
 <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sfbdl="http://www.snowflakesoftware.com/osopendata/boundaryline" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gss="http://www.isotc211.org/2005/gss" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gsr="http://www.isotc211.org/2005/gsr">
<wfs:Query typeName="sfbdl:WestminsterConstituency">
<ogc:Literal>Southampton, Itchen Boro Const</ogc:Literal>

Which returns that object from a WFS server; here's a link to some examples:

WFS Query Examples

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.