Developer’s Corner: GeoServer now supports Vector Footprints for ImageMosaic
with this blog post we want to introduce a new functionality which has been added lately to GeoServer for masking raster data configured as ImageMosaic stores by providing a vector footprint.
This feature is available if you use a version of GeoServer which is newer than 2.4.5. Full documentation can be found here.
Footprints can be configured in three different ways:
- By using for each mosaic granule a Sidecar File, a Shapefile with the same name of the granule which contains the footprint for it;
- By using a single Shapefile called footprints.shp which contains all the footprints for each granule; each footprint is associated to a granule with the location attribute;
- By using a file called footprints.properties .
The last option should be used when the first two are not available and requires to write the following piece of code inside the footprints.properties file:
footprint_source=*location of the Shapefile*
footprint_filter=*filter on the Shapefile searching for the attribute associated to each granule*
There are three possible behaviours for Footprint:
- None: simply doesn’t use the Footprint and behaves like a standard ImageMosaic layer;
- Transparent: adds an alpha band of 0s on the image portions outside of the Footprint making them transparent, typically used for RGB data;
- Cut: set the background value on the image portions outside of the Footprint, typically used for GrayScale data.
The behaviour must be set directly on the Layer configuration page.
Another feature of the Footprint is the possibility to calculate an Inset of the image. Inset is a reduction of the footprint border by a value defined by the user which is typically used for removing the compression artifacts. This feature can be achieved by adding the following code inside footprints.properties (in case of the first two configurations this file must be added):
footprint_inset=*value in the shapefile u.o.m.*
Full inset type calculates the inset for each footprint side while Border does the same operation but those straight lines that overlap the image bounds are avoided; this last parameter is useful for images already cut in a regular grid.
This is an example of mosaic without applying Footprint:
And this is the result of setting FootprintBehavior to Cut:
Background is gray because in this example the BackgroundValues field has been set to -20000.
If an Inset is added, the final mosaic is:
If you are interested in learning about how we can help you achieving your goals with our Open Source products and professional services, do not hesitate to contact us!
The GeoSolutions team,