We will demonstrate how to publish vector layers stored in a PostGIS as layer in Geoserver. We will be loading a vector file from our PostGIS server and publish it as a layer in Geoserver.
1. Login into the Geoserver admin page. Click on Add stores.
2. The New data source page should open. Select Postgis database.
3. The New Vector data Source page will open. At the beginning of the page assign a data source name and description(optional).
4.Scroll down to Connection Parameters section and fill in the credentials of the PostGIS database. Click Save at the end of the page to save the changes.
5. The New Layer page opens showing the vector files in the PostGIS database. For this demonstration, we select a line feature file – majorroads (see red boxed in the screenshot below).
6. The Edit Layer page opens next. Scroll down the page to the Coordinate Reference Systems section and use the Find button to declare a CRS for the layer. For the sample data, we are using the WGS 84. B) Scroll further down to the Bounding Boxes section and click on Compute from data to input the bounds of the layer. Click on Save at the bottom of the page to save the changes.
7. To view the layer we just published, A) Click on Layer Preview option to the left of the side panel B) Type in the name of the layer in the search bar C) Select the openlayers option beside the layer.
8. A new window will open and a graphical representation of the vector layer should display on the map canvas as seen on the screenshot below.
Thank you for following the blog.