How to Publish a Shapefile in GeoServer

This tutorial focuses on how to publish a shapefile in Geoserver assuming that GeoServer is already installed and running via the port assigned, for example, http://localhost:8080/geoserver.

Data Preparation

Firstly, prepare the data that you wish to upload on GeoServer,  that is the shapefile. For example, if you want to upload a shapefile for national parks, have the following files:

  • nationalparks.shx
  • nationalparks.shp
  • nationalparks.prj
  • nationalparks.dbf

Create a new Workspace

Secondly, create a new workspace that will store similar shapefile layers together. To do this, navigate to your localhost where GeoServer is hosted  http://localhost:8080/geoserver

  1. Log in to GeoServer using your username and password. The default username and password are admin and GeoServer respectively.
  2. On the left panel, under the Data section, select the Workspaces option.
Workspaces in GeoServer

3. Select Add new workspace.

You will be prompted to enter the name of the workspace and the URI.

Adding a new workspace in GeoServer

4. Enter the name as national_parks and the URI as shown above

5. Click on the Save button. The new workspace will be added to the list of existing workspaces.

Create a Store

Thirdly, add a new store for the shapefile. Adding a new store is a way to connect Geoserver with the shapefile.

  1. On the left panel, navigate to Data.
  2. Click on Stores.
Stores in GeoServer

3. Click on the Add new Store option.

Data Sources List in GeoServer

4. Under the Vector Data Sources option, navigate and click on the Shapefiles option.

5. In the Workspace* dropdown, select the previously created workspace. Choose a name for the new store.

6. Under the Connection Parameters, select the path to your locally stored shapefile by clicking the Browse option.

New Data Sources in GeoServer

7. Click Save.

Create a new Layer

  1. After the store has been created, publish the layer by clicking the publish option after the layer name.

On the edit layer page, enter the name, title and a short description of your layer.

Editing a layer in GeoServer

3. Set the coordinate system that matches your data. Type the code of the coordinate system to specify it. For example,  4326 for WGS 84 coordinate system.

CRS settings GeoServer

4. Set the bounding boxes for the layer by selecting compute from data and compute from native bounds options.

Bounding Boxes definitions in GeoServer

5. Click Save.

Preview the layer

The new layer appears on the layers list.

Click on the OpenLayers option next to the layer name.

Leave a Reply

Your email address will not be published. Required fields are marked *

Risper Mutinda

Hello. I am Risper Mutinda. I am a passionate Web and GIS Developer but more importantly, I am passionate about Technology.

More Reading

Post navigation