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/user_data/ directory and find the following shapefiles:

    Mainrd.shp
    Mainrd.shx
    Mainrd.dbf
    Mainrd.prj
    

    Copy the files to the following directory:

    $GEOSERVER_DATA_DIR/data/boulder
    

    Note

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

  2. Navigate to the GeoServer Welcome Page.

  3. On the Welcome page locate the Login form located at the top right corner, and enter the username “admin” and password “geoserver”.

    ../../_images/vector1.png

    GeoServer Login

  4. Click the Add stores link.

    ../../_images/vector2.png

    Add stores link

  5. Select the Shapefile link and click it.

    ../../_images/vector3.png

    Add a new shapefile

    Note

    The new data source menu 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.

  6. On the Edit Vector Data Source page enter “Mainrd” in the Data Source Name and Description fields. Finally click on browse link in order to set the Shapefile location in the URL field and click Save.

    Note

    The Mainrd.shp is located at data/boulder/Mainrd.shp

    ../../_images/vector4.png

    Specifying Shapefile parameters

  7. After saving, you will be taken to a page that lists all the layers in the shapefile and gives you the option to publish any of them. Click Publish.

    ../../_images/vector5.png

    Publishing a layer from the shapefile

  8. The Coordinate Reference Systems have to be manually populated. The Name and Title fields should be automatically populated.

    ../../_images/vector6.png

    Populate fields.

    Scroll down the page and generate the bounds for the layer by clicking the Compute from data button in the Bounding Boxes section.

    ../../_images/vector7.png

    Generating the layer bounding box

  9. Scroll to the bottom of the page, notice the read only Feature Type Detail table and then click Save.

    ../../_images/vector8.png

    Submitting the layer configuration

  10. If all went well, you should see something like this:

    ../../_images/vector9.png

    After a successful save

    At this point a shapefile has been added and is ready to be served by GeoServer.

    ../../_images/vector10.png
  11. Choose the preview link in the main menu and filter the layer list with mainrd:

    ../../_images/preview_shapefile1.png

    Selecting the mainrd shapefile in the layer preview

  12. Click on the OpenLayers link to preview the layer in an interactive viewer:

    ../../_images/preview_shapefile2.png

    The mainrd shapefile preview

In the next section we will see how to load a shapeFile into PostGIS.