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:8090/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 The extracted folder nyc_roads 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 Worksapce

  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. 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.


    Data Sources

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

  4. 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”).

  5. Under Connection Parameters specify the location URL of the Shapefile as file:data/nyc_roads/nyc_roads.shp.


    Basic Store Info and Connection Parameters

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

Create a Layer

  1. On the New Layer chooser page, select the layer nyc_roads.


    New Layer chooser

  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. Select the line style from the Default Style drop down list.


    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