#

## OpenGeo Stack Workshop

# Adding a Shapefile

The task of adding a Shapefile is one that is core to any GIS tool. This section covers the task of adding and publishing a Shapefile with GeoServer.

1. Navigate to the workshop `data/bayarea` directory and find the following files shapefiles:

       bay_area_coastline.shp
       bay_area_coastline.shx
       bay_area_coastline.dbf
       bay_area_coastline.prj

   Copy the files to the following directory:

       C:\Program Files\GeoServer 1.7.6\data_dir\data

   Note

   Ensure that all four parts of the shapefile are copied. This includes the `shp`, `shx`, `dbf`, and `prj` extensions.

   Copying the bay_area_coastline Shapefile

2. Navigate to the GeoServer Welcome Page.

3. From the Welcome page click on the Config link located on the left hand side.

   Configuring GeoServer

4. On the Login page, enter the username “admin” and password “geoserver”.

   Logging in

5. Click the Data link.

   Configure data link

6. Select the Data Stores link and click New.

   Configure data store link

   Add a new data store

7. Select Shapefile from the drop down list, enter “bay_area_coastline_shp” in the text box, and click New.

   Creating a new Shapefile data store

   Note

   The drop down list contains a list of all the spatial formats supported by GeoServer. When creating a new data store one of these formats must be chosen. Formats like Shapefile and PostGIS are supported by default, and many other formats are available as extensions.

8. On the Feature Data Set Editor page enter “file:data/bay_area_coastline.shp” in the url field, and click Submit.

   Specifying Shapefile parameters

9. On the Feature Type Editor page set the default style by selecting polygon from the Style drop down list.

   Note

   It is possible to attach any number of styles to a feature type or layer. Choosing one from the Style drop down sets the server default, which will be chosen when a client does not specify a style.

   Setting the layer style

   Warning

   A common mistake for new users is to set the default style for the feature type in the Additional Styles list, and not in the Style drop down.

   Mistakingly setting the default style

10. Scroll down the page and generate the bounds for the layer by clicking the Generate button.

    Generating the layer bounding box

11. Scroll to the bottom of the page and click Submit.

    Submitting the layer configuration

12. Finalize the changes by clicking Apply located in the top left corner of the page.

    Applying configuration changes

13. Persist changes by clicking Save.

    Note

    The GeoServer user interface follows a Submit-Apply workflow. When a change is made it will not take effect until it is Applied.

At this point a shapefile has been added and is ready to be served by GeoServer. In the next section the configuration will be verified with the Map Preview tool.

### Navigation

- index
- modules |
- next |
- previous |
- OpenGeo Stack Workshop »
- GeoServer Basics »
- Adding a Shapefile