Introduction

This page is intended to get the most out of GeoServer. The hints for data preparation and optimalisation provide data administrators with some good data handling principles and provide performant data services to end users. Basically, GeoServer is a spider in the web of various spatial data formats and OGC data services. More about GeoServer can be found at the  website.

Short about Geoserver

One of the key features of GeoServer is its ability to optimize data output, ensuring that large datasets are delivered efficiently and effectively to clients. This is particularly important for geospatial applications, where datasets can be massive and complex, and where fast data delivery is critical for a smooth user experience. By optimizing data output, GeoServer enables users to reduce bandwidth usage, improve rendering times, and increase overall system performance. This wiki page will explore the various techniques and strategies used by GeoServer to optimize data output, including data caching, tiling, compression, and more, and will provide guidance on how to configure and fine-tune these optimizations for specific use cases.

In addition to GeoServer's ability to optimize data output, it is also the responsibility of the data provider to ensure that the data being served is optimized for delivery. This means that data providers have an important role to play in preparing and optimizing their data to take full advantage of GeoServer's optimization capabilities, and to minimize the load on the server and network. By optimizing their data, providers can help to reduce the burden on GeoServer, improve performance, and ensure that their data is delivered efficiently and effectively to end-users. 

This page offers a collection of tips and best practices for setting up optimized data inputs in GeoServer, covering both raster and vector data formats. By following these guidelines, users can ensure that their data is properly configured to take advantage of GeoServer's optimization capabilities, resulting in improved performance, reduced bandwidth usage, and faster rendering times. The tips and recommendations provided here will be organized by data type, with separate sections focusing on optimal setup for raster and vector data formats. 

General best practices

Let's kick in the door of best practicies with the remarkt to provide your data with an appropriate Coordinate Reference System. Seems obvious, but .... data is often is not properly georeferenced and generations of users have learned to deal with non georeferenced data. But .... GeoServer cannot handle that. That becomes clear in the block Coordinate Reference System. In GeoServer, if you follow the normal recipe (create workspace, define store and publish data) you can encounter ...

Using QGIS, unreferenced data can be recognized by a ? and via gdalinfo (in this case of a raster dataset) via the following message.

There are several ways to overcome this, except for 'educating' your data provider which is the better option off course. Providing data with appropriate CRS depends on the data format. The following bullets give a distinction in assigning CRS to raster and vector, but are not exhaustive.

Raster formats

Optimizing raster formats is pretty straight forward. Make sure you have a COG, a cloud optimized geotiff. There are a couple of instruments you can use to create COG's (COG raster files). QGIS offers tools to do that, but in case you have a lot of GTIFF's (or other rasterfiles) it is usefull to use the GDAL application gdalwarp (see link for more information). In the code below you find a snippet of the generic command.

gdalwarp generic code
gdalwarp src1.tif src2.tif out.tif -of COG

Recap ... transforming a raster file to GTIFF with the option -of COG already performs a transformation to a basic Cloud Optimize GeoTIFF with internal tiling and compression parameters. The gdalwarp page provides more options to even optimize further.

Vector formats

While it may seem like a straightforward issue, optimizing data input in GeoServer can be complex due to the multiple formats supported and the various pathways to optimization. However, one combination that consistently yields the best performance is the use of PostgreSQL/PostGIS in conjunction with GeoServer. PostGIS, in particular, offers several powerful tools to optimize the data experience, with PostGIS Spatial Indexing and Primary Keys being the most notable. By leveraging these indexes and keys, users can significantly improve the efficiency and speed of their data delivery. Setting up these indexes and keys is a relatively straightforward process, but it does require access to a PostgreSQL/PostGIS database and a certain level of technical expertise. Although PostgreSQL/PostGIS is a standard tool provided by Deltares IT (see topdesk link, can only be used by Deltares employees), its steep learning curve can present a barrier to entry for some users, making it essential to invest time and effort into mastering its capabilities. But this will pay off! Especially if datasets are dynamic and/or big. 

Another option is working with the other supported (by GeoServer) database based format, GeoPackage. Here you can also apply geospatial indexing, again via a gdal application. In this case the application is called gdalladdo. In QGIS you have the option to transform any vector format to a GPKG, including the option of spatial indexing.  To optimize a GeoPackage for use in GeoServer, follow these steps:

  1. Create a spatial index: Use the gdaladdo command-line tool with the -index option to create a spatial index on the geometry column of each feature table in the GeoPackage. For example, you can use the following command: gdaladdo -index input.gpkg
  2. Add overviews: Use the gdaladdo command-line tool to add overviews to the GeoPackage. Overviews are lower-resolution versions of the data that can be used to speed up rendering and querying. For example, you can use the following command: gdaladdo -r average input.gpkg 2 4 8 16
  3. Verify the spatial index: Use QGIS to verify that the spatial index has been created correctly. You can do this by opening the GeoPackage in QGIS and checking the layer properties to see if the spatial index is listed.
  4. Optimize the GeoPackage: Use QGIS to optimize the GeoPackage by running the Optimize GeoPackage tool. This tool can be found in the Database > GeoPackage menu.
  5. Check the spatial reference system: Ensure that the spatial reference system (SRS) used in the GeoPackage matches the one used in your GeoServer instance.
  6. Test and verify: Test the optimized GeoPackage in GeoServer to verify that it is working as expected and that the spatial index and overviews are being used correctly.

By using the -index option with gdaladdo, you can create a spatial index that is optimized for use with GeoServer, which can significantly improve the performance and efficiency of your geospatial data. Additionally, using QGIS to verify and optimize the GeoPackage can help ensure that the data is correctly formatted and ready for use in GeoServer.

Advice is not to use other formats, altough supported by GeoServer, due to the lack of geospatial indexing. 

  • No labels