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.
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
Navigate to the GeoServer Welcome Page.
From the Welcome page click on the Config link located on the left hand side.
Configuring GeoServer
On the Login page, enter the username “admin” and password “geoserver”.
Logging in
Click the Data link.
Configure data link
Select the Data Stores link and click New.
Configure data store link
Add a new data store
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.
On the Feature Data Set Editor page enter “file:data/bay_area_coastline.shp” in the url field, and click Submit.
Specifying Shapefile parameters
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
Scroll down the page and generate the bounds for the layer by clicking the Generate button.
Generating the layer bounding box
Scroll to the bottom of the page and click Submit.
Submitting the layer configuration
Finalize the changes by clicking Apply located in the top left corner of the page.
Applying configuration changes
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.