Publishing a Shapefile

This tutorial walks through the steps of publishing a Shapefile with GeoServer.


This tutorial assumes that GeoServer is running at http://localhost:8080/geoserver/web.

Getting Started

  1. Download the file This archive contains a Shapefile of roads from New York City that will be used during in this tutorial.

  2. Unzip the into a new folder named nyc_roads. The zip archive contains the following four files:


#. Move the nyc_roads folder into <GEOSERVER_DATA_DIR>/data, where <GEOSERVER_DATA_DIR> is the root of the GeoServer data directory. If no changes have been made to the GeoServer file structure, the path is geoserver/data_dir/data/nyc_roads.

Create a New Workspace

The first step is to create a workspace for the Shapefile. A workspace is a container used to group similar layers together.

  1. In a web browser navigate to http://localhost:8080/geoserver/web.

  2. Log into GeoServer as described in Logging In.

  3. Navigate to Data‣Workspaces.


    Workspaces page

  4. To create a new workspace click the Add new workspace button. You will be prompted to enter a workspace Name and Namespace URI.


    Configure a New Workspace

  5. Enter the Name as nyc_roads and the Namespace URI as A workspace name is a identifier describing your project. It must not exceed ten characters or contain spaces. A Namespace URI (Uniform Resource Identifier) is typically a URL associated with your project, perhaps with an added trailing identifier indicating the workspace.


    NYC Roads Workspace

  6. Click the Submit button. The nyc_roads workspace will be added to the Workspaces list.

Create a Data Store

  1. Navigate to Data‣Stores.
  2. You should see a (possibly empty) list of data stores, including the type of store and the workspace that the store belongs to.

#. In order to add the nyc_roads Shapefile, you need to create a new Store. Click on 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.


Data Sources

  1. Select Shapefile - ESRI(tm) Shapefiles (*.shp). The New Vector Data Source page will display.

  2. Begin by configuring the Basic Store Info. Select the workspace nyc_roads from the drop down menu. Enter the Data Source Name as NYC Roads. and enter a brief Description (such as “Roads in New York City”).

  3. Under Connection Parameters, browse to the location URL of the Shapefile, typically file:nyc_roads/nyc_roads.shp.


    Basic Store Info and Connection Parameters

  4. Click Save. You will be redirected to the New Layer page in order to configure the nyc_roads layer.

Create a Layer

  1. On the New Layer page, select Publish beside the nyc_roads layer name.


    New Layer

  2. The Edit Layer page defines the data and publishing parameters for a layer. Enter a short Title and an Abstract for the nyc_roads layer.


    Basic Resource Information

  3. Generate the layer’s bounding boxes by clicking the Compute from data and then Compute from native bounds.


    Generate Bounding Boxes

  4. Set the layer’s style by switching to the Publishing tab.

  5. Under WMS Settings, ensure that the Default Style is set to line.


    Select Default Style

  6. Finalize the layer configuration by scrolling to the bottom of the page and clicking Save.

Preview the Layer

  1. In order to verify that the nyc_roads layer is published correctly you can preview the layer. Navigate to the Layer Preview screen and find the nyc_roads:nyc_roads layer.


    Layer Preview

  2. Click on the OpenLayers link in the Common Formats column.

  3. Success! An OpenLayers map loads in a new page and displays the Shapefile data with the default line style. You can use the Preview Map to zoom and pan around the dataset, as well as display the attributes of features.


    Preview map of nyc_roads