OpenGeo

OpenGeo Stack Workshop

Previous topic

GeoServer Basics

Next topic

Using the Map Preview

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.

    ../_images/shapefile_add1.png

    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.

    ../_images/shapefile_add2.jpg

    Configuring GeoServer

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

    ../_images/shapefile_add3.jpg

    Logging in

  5. Click the Data link.

    ../_images/shapefile_add4.jpg

    Configure data link

  6. Select the Data Stores link and click New.

    ../_images/shapefile_add5.jpg

    Configure data store link

    ../_images/shapefile_add6.jpg

    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.

    ../_images/shapefile_add7.jpg

    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.

    ../_images/shapefile_add8.jpg

    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.

    ../_images/shapefile_add9.jpg

    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.

    ../_images/shapefile_add10.jpg

    Mistakingly setting the default style

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

    ../_images/shapefile_add11.jpg

    Generating the layer bounding box

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

    ../_images/shapefile_add12.jpg

    Submitting the layer configuration

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

    ../_images/shapefile_add13.jpg

    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.