40. GeoServer Guide¶
40.1 Installation (Linux)¶
- Make sure you have a Java Runtime Environment (JRE) installed on your system. GeoServer requires Java 11 or Java 17, available from OpenJDK, Adoptium, or your OS distribution.
Note: For more information about Java and GeoServer compatibility, please see the section on Java Considerations.
-
Navigate to the GeoServer Download page.
-
Select the version of GeoServer that you wish to download. If unsure, select the Stable release.
These instructions are for GeoServer 2.27-SNAPSHOT, provided as a Nightly release. Testing a Nightly release is a great way to try out new features and test community modules. Nightly releases change on an ongoing basis and are not suitable for a production environment.
-
Select Platform Independent Binary on the download page: geoserver-2.27.x-latest-bin.zip.
-
Download the
zip
archive and unpack it in your preferred location.
Note: A suggested location would be
/usr/share/geoserver
.
- Add an environment variable to save the location of GeoServer:
- Make yourself the owner of the
geoserver
folder (replaceUSER_NAME
with your username):
- Start GeoServer by changing into the
geoserver/bin
directory and running thestartup.sh
script:
- Open a web browser and navigate to:
If you see the GeoServer Welcome page, then GeoServer is successfully installed.
- To shut down GeoServer, either close the persistent command-line window or run the
shutdown.sh
file inside thebin
directory.
40.2 Uninstallation¶
- Stop GeoServer (if it is running).
- Delete the directory where GeoServer is installed.
40.3 Getting Started¶
40.4 Using the web administration interface¶
GeoServer has a browser-based web administration interface application used to configure all aspects of GeoServer, from adding and publishing data to changing service settings.
- The web admin interface is accessed via a web browser at:
- For a default installation on a server, the link is:
- When the application starts, it displays the Welcome page.
- The welcome page provides links describing the web services used to access information.
To use, copy and paste these links into a Desktop GIS, mobile, or web mapping application.
Note: For more information, please see the Welcome section.
40.5 Logging In¶
In order to change any server settings or configure data, a user must first be authenticated.
- Navigate to the upper right of the web interface to log into GeoServer. The default administration credentials are:
- User name:
admin
- Password:
geoserver
- Once logged in, the Welcome screen changes to show the available admin functions. These are primarily shown in the menus on the left side of the page.
40.6 Layer Preview¶
The Layer Preview page allows you to quickly view the output of published layers.
- Click the Layer Preview link on the menu to go to this page.
-
From here, you can find the layer you’d like to preview and click a link for an output format. Click the OpenLayers link for a given layer and the view will display.
-
To sort a column alphabetically, click the column header.
- Searching can be used to filter the number of items displayed. This is useful for working with data types that contain a large number of items. To search data type items, enter the search string in the search box and press Enter. GeoServer will search the data type for items that match your query and display a list view showing the search results.
Hint Perform an exact term search by enclosing the search term in quotes or double-quotes, e.g. normally
ads
would also matchroads
, but"ads"
wouldn’t.Note Sorting and searching apply to all data configuration pages.
- For more information, please see the Layer Preview section.
41. Publishing a GeoPackage¶
This tutorial walks through the steps of publishing a GeoPackage with GeoServer.
Note
This tutorial assumes that GeoServer is running at
http://localhost:8080/geoserver
.
41.1 Data Preparation¶
First, let’s gather the data that we’ll be publishing.
- The sample data folder includes
data/ne/natural_earth.gpkg
. - This file contains small scale 1:110m data:
- Coastlines
- Countries
- Boundary lines
- Populated places
Note
The
data/ne/natural_earth.gpkg
file has been processed from Natural Earth Data. To download the original file, visit the site and download the GeoPackage link.
41.2 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.
Note This step is optional if you would 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
http://localhost:8080/geoserver
. - Log into GeoServer as described in the Logging In section.
- Navigate to Data → Workspaces.
- Click the Add new workspace button to display the New Workspace page.
- Enter the following details:
Field | Value |
---|---|
Name | tutorial |
Namespace URI | http://localhost:8080/geoserver/tutorial |
Note A workspace name is an identifier describing your project. It must not exceed ten characters or contain spaces.
Note A Namespace URI can be a URL associated with your project with an added trailing identifier indicating the workspace. The Namespace URI field does not need to resolve to an actual valid web address.
-
Press the Submit button.
-
The
tutorial
workspace will be added to the Workspaces list.
41.3 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.
- Navigate to Data → Stores.
-
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.
- Enter the following details:
Field | Value |
---|---|
Workspace | tutorial |
Data Source Name | NaturalEarth |
Description | GeoPackage of NaturalEarth data |
- Under Connection Parameters, browse to the location of the GeoPackage:
- Database:
file:data/ne/natural_earth.gpkg
-
Read only: checked
-
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.
-
Press Save. You will be redirected to the New Layer page.
41.4 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 countries
layer name
. -
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:
Field Value Name Countries
Title Countries
Abstract Sovereign states
-
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 Coordinate Reference Systems information is correct.
Field | Value |
---|---|
Native SRS | EPSG:4326 |
Declaired SRS | EPSG:4326 |
SRS Handling | Force declared |
- Locate Bounding Boxes 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 polygon`.
- Press Save to complete your layer edits.
41.5 Previewing the layer¶¶
In order to verify that the tutorial:countries
layer is published correctly, we can preview the layer.
- Navigate to the Data > Layer Preview page and find the tutorial:countries layer.
Note: 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.
42. Publishing an Image¶
This tutorial walks through the steps of publishing a World + Image with GeoServer.
Note: This tutorial assumes that GeoServer is running at
http://localhost:8080/geoserver
.
42.1 Data Preparation¶
First, let us gather the data that we will be publishing.
- Download the Natural Earth 1:50m Shaded Relief raster:
-
https://www.naturalearthdata.com/downloads/50m-raster-data/50m-shaded-relief/
-
This file contains small-scale 1:50m data:
SR_50M.prj
SR_50M.README.html
SR_50M.tfw
SR_50M.tif
SR_50M.VERSION.txt
This forms a world (tfw
file) plus image (tif
file).
- Move these files into your GeoServer Data Directory
data/ne
folder.
42.2 Creating a New Workspace¶
The next step is to create a workspace for the data. A workspace is a folder used to group similar layers together.
Note: 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
http://localhost:8080/geoserver
. - Log into GeoServer.
- Navigate to Data > Workspaces.
- Click Add new workspace to display the New Workspace page.
- Enter the following details:
- Name:
tutorial
- Namespace URI:
http://localhost:8080/geoserver/tutorial
Note: A workspace name is an identifier describing your project. It must not exceed ten characters or contain spaces.
Note: A Namespace URI (Uniform Resource Identifier) can usually be a URL associated with your project with an added trailing identifier indicating the workspace. It does not need to resolve to a valid web address.
- Press Submit.
- The
tutorial
workspace will be added to the Workspaces list.
42.3 Creating a Store¶
Once the workspace is created, we are ready to add a new store. The store tells GeoServer how to connect to the image.
- Navigate to Data‣Stores.
- 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 data sources supported by GeoServer. Note that data sources are extensible, so your list may look slightly different.
- From the list of Raster Data Sources locate and click the WorldImage link.
-
The New Vector Data Source page will display.
-
Begin by configuring the Basic Store Info.
workspace | tutorial |
---|---|
Data Source Name | ShadedRelief |
Description | Grayscale shaded relief of land areas. |
- 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 it 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 location of your data.
-
Under Connection Parameters, browse to the location URL of the image, in our example file:data/ne/SR_50M.tif.
-
The Connection Parameters for our geopackage are:
database : file:data/ne/SR_50M.tif
- Press
save
.
42.4 Creating a Layer¶
Now that we have located the image, we can publish it as a layer.
-
On the New Layer page, click Publish beside the SR_50M layer name.
-
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:
Name | shaded |
---|---|
Title | Shaded Relief |
Abstract | Grayscale shaded relief of land areas. |
-
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.
-
Check the Coordinate Reference Systems information.
-
Locate Bounding Boxes and generate the layer’s bounding boxes by clicking the Compute from SRS bounds 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 raster.
43. Publishing a Layer Group¶
Note: This tutorial assumes that GeoServer is running at
http://localhost:8080/geoserver
.
43.1 Data preparation¶
First let us gather the data that we will be publishing.
- Complete the previous tutorials:
- Publishing a GeoPackage defining the
tutorial:countries
layer - Publishing an Image defining the
tutorial:shaded
layer
43.2 Create a layer group¶
- Navigate to Data > Layer Group page.
- This page displays a list of layer groups and the workspace the group belongs to.
Note: Layer groups can be “global”, allowing a map to be created combining layers from several workspaces into a single visual.
-
At the top of the Layer Groups list, click Add new layer group.
-
The Layer group editor defines:
- 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
-
Layers - the layers to be drawn (listed in draw order)
-
Locate Basic Resource Info and define the layer:
Name | basemap |
---|---|
Title | Basemap |
Abstract | Plain basemap suitable as a backdrop for geospatial data. |
Workspace | tutorial |
-
Scroll down to the Layers list, which is presently empty.
-
Click Add Layer, select the
tutorial:shaded
layer first. -
The raster should be drawn first, as other content will be shown over top of it.
-
Click Add Layer, select the
tutorial:countries
layer second. -
This polygon layer will be drawn second.
-
Locate the
tutorial:countries
layer in the list and click the Style entry to changepolygon
toline
. -
By drawing only the outline of the countries, the shaded relief can show through.
-
Locate Coordinate Reference Systems and press Generate Bounds.
- Now that layers are listed, they can be used to determine the coordinate reference system and bounds of the layer group.
-
Press Save to complete your layer group.
44. Publishing a style¶
This tutorial walks through the steps of defining a style and associating it with a layer for use.
Note This tutorial assumes that GeoServer is running at
http://localhost:8080/geoserver
.
44.1 Create a style¶
- Navigate to Data > Style page.
- This page displays a list of styles, including the workspace the style belongs to.
Note
Styles groups are allowed to be "global," allowing a style to be defined and used by any layer.
-
At the top of the Styles list, locate and click the Add a new style link.
-
Locate Style Data and define the style:
Name | Value |
---|---|
Name | background |
Workspace | tutorial |
Format | SLD |
- Locate Style Content and configure:
-
Under Generate a default style, select
Polygon
. -
Click the Generate link to populate the style editor with a generated outline of a polygon style.
-
Press the Apply button to define this style.
-
Now that the style is defined, there are more options for interactively working with the style.
-
Change to the Publishing tab.
- Use the search to filter with
tutorial
to locatetutorial:countries
. -
Check the Default checkbox for
tutorial:countries
to use thetutorial:background
style as the default for this layer. -
Navigate to the Layer Preview tab.
-
Locate Preview on layer and click on the link to select
tutorial:countries
as a dataset to use when editing the style. -
Edit your style by inserting
fill-opacity
value of0.25
.
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>background</Name>
<UserStyle>
<Title>Background</Title>
<FeatureTypeStyle>
<Rule>
<Title>Background</Title>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#444433</CssParameter>
<CssParameter name="fill-opacity">0.25</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">0.25</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
-
Press Apply to edit your style and check the resulting visual change in the layer preview.
-
For more information you can go with Official docs