Thursday 21 May 2015

qgis - How can I serve data from a single PostGIS view, via WMS/WFS, in a way that allows users in a GIS client to filter based on attributes?


I have a materialized VIEW in PostgreSQL/PostGIS that contains observations for thousands of species. I am currently serving this view as a single WMS/WFS layer using Geoserver, and this works fine for our web applications. We just use a CQL filter in the application to limit to the species selected by the user. But, I am not sure of the best way to get the data to end users in a GIS client (ArcMap mostly, but also QGIS), who will almost always want to view observations for a single species at a time. Although SQL filters can be applied to a WFS layer in QGIS, I am not sure about ArcMap. Also, it might be too much to ask to suggest that end users form and apply these queries in their GIS client, since most end users will be biologists, rather than GIS or database specialists. The options I can think of that might be viable are:


1) Serve the data as-is, and ask end users to filter by species on their end.


2) Programmatically create a separate layer for each species, possibly as layer groups, in Geoserver, grouped by major taxonomic groupings (e.g., Birds, Mammals, etc.). This is problematic because the data change on a daily basis, so views/layers would have to be regenerated frequently.


Are there other options I might be missing?



Answer



The responses to another question on Stack gave me the answer I was looking for. I was able to make use of the custom parameters (see linked question for samples) on the WMS layer in ArcMap to filter to a particular species. In short, with ArcMap 10.4 and up, you can specify custom parameters by double-clicking the name of the WMS service (note that you must click the service name, not the individual layer name), and specifying a CQL_FILTER in the Parameters tab. Note that no validation is performed by ArcMap, because it doesn't even understand the parameter you're asking it to pass -- it just passes the parameter to the map server, and if nothing is returned, so be it. One thing that tripped me up is the formatting of the CQL_FILTER. The filter should look like the following:


comname = 'Northern Pintail'


Sample CQL_FILTER specification in ArcMap



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...