Developers Corner: have your SLD transform raster data into vectors on the fly
- call the WPS with the given data
- store the results somewhere
- register that new layer as a published WMS layer, along with the proper style
- update the viewer to add that layer
- purge that temporary layer once the user is done or wants a different set of parameters to be applied in the transformations
Instead of doing all of the above work, wouldn’t it be nice to just specify the transformation needed in the style sheet? That’s exactly the road we decided to follow.
We’ve created and SLD extension allowing to pipe a process (yes, a WPS one) inside the SLD so that it can be dinamically updated. It looks like the following:
The above would call on the fly the contouring process and then render its result: no need to create and manage a new vector layer, the data is generated on the fly only when needed.
Here is how the result looks (using a style sheet just a bit more complex than the above one):
Chaining transformations we can also extract and display the value of the single pixels and show it as a label, as in the following example:
Alternatively you may want to extract the polygons containing all the cells in a certain data range, like in the following transformation:
The result, coloring each range in a different way, is:
Finally, we may want to extract as set of wind arrows starting from a raster having the horizontal and vertical components of a vector (u and v):
We’re linking to the full SLD of this last one because it’s quite the testament of SLD flexibility: the magnitude and direction of the arrow are computed on the fly by using filter functions (functions that are part of GeoTools/GeoServer, you may not find them in just any implementation).
This makes it possible to get fast, on the fly operations that do not excessively slow down rendering.
This is yet another example of how processing capabilities can be integrated into GeoServer, and it’s by no means the last. Also, there is still plenty that can be done to improve this kind of transformations, as well as new transformations to support mapping tools such as heatmaps. Interested? Let us know!