|Setting up a WFS in GeoServer using a Shapefile|
By completing this tutorial, you will be able to set up a Web Feature Service (WFS) in GeoServer with a shapefile. The process for setting up a WFS in GeoServer requires the creation of 3 main components: a Workspace, Store, and Layer. You can use existing workspaces and stores to set up your layer but in this tutorial we will be creating new ones.
A workspace is used as a grouping of similar layers. In this case we will call our workspace “Vancouver”.
A store is used to make the connection to our shapefile. We will call our store “City Blocks”.
A layer is the actual GIS data itself. We will call our layer “blocks”.
The first thing you need to do is download the sample data for Vancouver’s city blocks. Place the shapefile in your data directory. I have placed mine in the data_dir/data/shapefiles directory that I set up when installing GeoServer. The data_dir is under the root of the GeoServer installation.
Sign into GeoServer and click the “Create workspaces” link.
Under Name, enter “Vancouver”. Under Namespace URI, enter something that relates to your project. This is typically a URL. For this example I have used “blocks”. Click Submit.
Go back to the GeoServer administrator home by clicking its logo. This time click the “Add stores” button. Under “Vector Data Sources” choose “Shapefile”.
Under Workspace, choose “Vancouver”. For the Data Source Name, enter “City Blocks”.
Under URL, you must enter the absolute path to your shapefile, or the relative path from your data directory. In this case we will enter a relative path “file:data/shapefiles/blocks.shp”. Click Save.
You will be taken to the new layer chooser. Click Publish for your blocks layer.
Under Coordinate Reference Systems > Native SRS, you will see that it is UNKNOWN. But we know that our data is NAD83 UTM Zone 10 North. We will specify this under “Declared SRS”. Enter “EPSG: 26910”.
You should notice GeoServer recognizes this as “EPSG:NAD83 / UTM zone 10N...”.
Under Bounding Boxes >Native Bounding Box, click the “Compute from data” link.
Under Lat/Lon Bounding Box, click the “Compute from native bounds” link and click Save.
Your shapefile is now set up for use as a WFS. To preview your layer, click on “Layer Preview” in the GeoServer menu, find the “Vancouver:blocks” layer and select your desired format.
The user is now able to serve shapefiles as Web Feature Services through GeoServer.