Publishing a GeoPackage¶
This tutorial walks through the steps of publishing a GeoPackage with GeoServer.
This tutorial assumes that GeoServer is running at
First let’s gather that the data that we’ll be publishing.
Creating a new workspace¶
The next step is to create a workspace for the geopackage. A workspace is a folder used to group similar layers together.
This step is optional if you’d like to use an existing workspace. Usually, a workspace is created for each project, which can include stores and layers that are related to each other.
In a web browser, navigate to
Log into GeoServer as described in the Logging In section.
Click the Add new workspace button to display the New Workspace page.
You will be prompted to enter a workspace Name and Namespace URI.
A workspace name is an identifier describing your project. It must not exceed ten characters or contain spaces.
A Namespace URI (Uniform Resource Identifier) can usually be a URL associated with your project with an added trailing identifier indicating the workspace. The Namespace URI filed does not need to resolve to an actual valid web address.
Press the Submit button.
tutorialworkspace will be added to the Workspaces list.
Create a store¶
Once the workspace is created, we are ready to add a new store. The store tells GeoServer how to connect to the geopackage.
This page displays a list of stores, including the type of store and the workspace that the store belongs to.
In order to add the geopackage, you need to create a new store. Click the Add new Store button. You will be redirected to a list of the data sources supported by GeoServer. Note that the data sources are extensible, so your list may look slightly different.
From the list of Vector Data Sources locate and click the GeoPackage link.
The New Vector Data Source page will display.
Begin by configuring the Basic Store Info.
Data Source Name
GeoPackage of NaturalEarth data
This information is internal to GeoServer and is not used as part of the web service protocols. We recommend keeping the Data Source Name simple as they will be used to form folders in the data directory (so keep any operating system restrictions on character use in mind).
Connection parameters are used to establish the connection with your database. As GeoPackage is a file based database this will primarily consist of the geopackage location.
Under Connection Parameters, browse to the location URL of the geopackage, in our example
The Connection Parameters for our geopackage are:
The use of read_only above indicates that we will not be writing to this GeoPackage, allowing GeoServer to avoid managing write locks when accessing this content for greater performance.
You will be redirected to the New Layer page (as this is the most common next step when adding a new data store).
Creating a layer¶
Now that we have connected to the GeoPackage, we can publish the layer.
On the New Layer page, click Publish beside the
The Edit Layer page defines the data and publishing parameters for a layer.
There are three critical pieces of information required on the Data tab before we can even save.
Basic Resource Info - describes how the layer is presented to others
Coordinate Reference System - establishes how the spatial data is to be interpreted or drawn on the world
Bounding Boxes - establishes where the dataset is located in the world
Locate Basic Resource Info and define the layer:
The naming of a layer is important, and while GeoServer does not offer restrictions many of the individual protocols will only work with very simple names.
Double check the Coordiante Reference Systems information is correct.
Locate Bounding Boces and generate the layer’s bounding boxes by clicking the Compute from data and then Compute from native bounds links.
Press Apply to save your work thus far without closing the page.
This is a good way to check that your information has been entered correctly, GeoServer will provide a warning if any required information is incomplete.
Scroll to the top of the page and navigate to the Publishing tab.
Locate the WMS Settings heading, where we can set the style.Ensure that the Default Style is set to
Press Save to complete your layer edits.
Previewing the layer¶
In order to verify that the
tutorial:countries layer is published correctly, we can preview the layer.
Navigate to thepage and find the
Use the Search field with tutorial as shown to limit the number of layers to page through.
Click the OpenLayers link in the Common Formats column.
An OpenLayers map will load in a new tab and display the shapefile data with the default line style.
You can use this preview map to zoom and pan around the dataset, as well as display the attributes of features.