../../_images/logo_geoserver.png ../../_images/OSGeo_project.png

GeoServer Quickstart

GeoServer is a java application for serving maps (and data) for other clients (such as web browsers) to draw. GeoServer comes with a browser-based management interface and connects to multiple data sources at the back end.

This Quick Start describes how to:

  • add a vector and raster data source to GeoServer

  • apply color to map features using styling

  • test the layers in a simple web map

  • learn about clients that can display your maps

  • add a layer from a NetCDF file

Start Geoserver

  1. From the Start menu, select Geospatial ‣ Web Services ‣ GeoServer ‣ Start GeoServer. The application will take a few moments to start up and will open a web page at http://localhost:8082/geoserver/web

    ../../_images/geoserver-login.png
  2. Log in using the username admin and password geoserver. You will now see the admin page.

    ../../_images/geoserver-welcome.png
  3. Select the Layer Preview link at the top of the Data section in the left hand menu to see a preview of the layers that are loaded on the server.

    ../../_images/geoserver-layerpreview.png
  4. Scroll to the bottom of the page and click on the OpenLayers link in the tiger-ny row. This will open a new window with a preview of some of the sample data.

    ../../_images/geoserver-preview.png
  5. You can zoom in to the map in three ways:

  • by clicking on the zoom bar on the left, the higher you click on it the more zoomed in you will see.

  • by using the mouse scroll wheel (if you have one), scrolling up will zoom in and down will zoom out.

  • by dragging a box on the map while holding down the shift key - this will zoom in to the box selected (or as near as will fit in the screen).

Experiment with this view and look at some of the other previews. Once you are comfortable viewing existing data you can move on to adding some new data.

Loading data

Note

You will not be able to carry out the following steps if you are running with a read only file system (such as the DVD). You will either need to run in a Virtual Machine, or from a USB, or install OSGeoLive (or just GeoServer) onto your hard drive.

In this example we are going to use the Natural Earth data set that is included on OSGeoLive (/usr/local/share/data/natural_earth2/).

  1. We need to create a Store for our data. From the GeoServer admin page go to Stores.

  2. Click on Add new Store. You will see this page:

    The New Store page
  3. Select the Directory of spatial files. You will see the following:

    Filling in the New Store page
  4. Type in a name for the Data Store (for example, Natural Earth) and fill in the URL to the data set - in this case /usr/local/share/data/natural_earth2/. You can use the browse button to find the directory if your data is somewhere else.

  5. Press save.

    The Natural Earth Datastore
  6. Press publish next to one of the layers to finish adding the data. This will take you to the Layers page:

    The layer publishing page

    As you scroll down the page you will see that GeoServer has filled in many of the fields for you. When you reach Coordinate Reference System you will notice that under Native SRS it says UNKNOWN you will need to fill in the next box (declared SRS) to make sure GeoServer knows where the data is.

  7. You can type epsg:4326 in the box

  8. Click on Compute from data and Compute from native bounds to fill in the Bounding Boxes.

  9. Finally hit save and you have published your first layer.

Note

Don’t worry if the layer preview doesn’t look very good as it is using the default style. In the next section we will look at producing a nicer style.

You can follow the same step with the other layers in the directory by using the Add a new resource button on the layers page. Just select the natural earth store from the drop down box to get back to the store’s page.

Styling data

Styling a data set into a map layer GeoServer uses an OGC standard called Styled Layer Descriptor (SLD). These are represented as XML files which describe the rules that are used to apply various symbolizers to the data.

To get started, lets style the Land and Ocean datasets. You can create SLD files using a simple text editor, but sometimes a graphical editor is better. There are several options here but uDig allows you to open the shapefiles directly and apply simple styles using a GUI. It also provides a simple editor to modify the XML if I need to.

Using uDig to create simple styles

Note

For more details on how to use uDig see the uDig Quickstart

  1. Open uDig and add the shapefiles (using the add data button in the top left hand corner).

  2. Drag the ne_10m_land and ne_10m_ocean tables into the map window. uDig automatically applies a style (so you can see the data).

    Default Styling in uDig
  3. In the Layer list select the style button (it looks like an artist’s palette).

    The Layer list window

    This will open the Style Pane.

  4. In the simple window we can easily select a nice blue for the oceans by clicking on the colored box on the fill tab and choosing from the color picker it produces. We can also increase the opacity of the fill to 100% to make the color look better. Pick the same blue for the border color so it will match.

    The Style Pane
  5. Click OK and uDig will display the changes.

    Blue Oceans
  6. Repeat the steps above to change the color of the land layer. You can use the define custom colors section to create your preferred color.

    Defining a nicer land color

This gives a nice looking basic world map.

A basic word map

Adding the style to GeoServer

Now we need to transfer these styles to GeoServer.

  1. On the style window there is an export button which allows you to save the SLD file that defines your style.

  2. Once saved, you can go to the GeoServer admin page again and select Styles (at the bottom of the Data section).

  3. Select the Add New Style link. At the bottom of that page is a file upload box and a browse button.

  4. Clicking browse to find the files you just saved.

  5. Click the upload link (next to the browse button) and a copy of the file appears in the editor.

  6. If you click on the validate button the highlighted lines will give you an error but you can safely ignore the error (or delete those lines as they don’t do anything).

  7. Press the Submit at the bottom of the page.

Adding a Style to GeoServer

Adding the style to the layer

  1. Click on the Layers link in the Menu on the left of the GeoServer window.

  2. Click on the layer (e.g. ne_10m_land), then select the Publishing tab.

  3. Change the Default Style box to the name of the style you uploaded in the previous section.

  4. Now click Save and go to the Layer Preview page to check that it looks good.

Note

There are example style files for all of the example Natural Earth layers in /usr/local/share/geoserver.

Clients for WMS layers

The Web Map Service (WMS) layers you are serving from GeoServer can be used with a variety of clients on this OSGeoLive distribution, including:

Add a layer from a NetCDF file

The GeoServer NetCDF plugin allows the publication of rasters from NetCDF files.

Configure a NetCDF store

  1. After running “Start GeoServer”

  2. Login as the administrator.

  3. Click on Add stores then NetCDF.

  4. Enter a value for Data Source Name (this example uses “netcdf”) and a NetCDF URL. You can use this sample file:

    file:///usr/local/share/data/netcdf/polyphemus_20120401.nc
    
  5. Press “Save”, “Publish” the “O3” layer.

  6. Scroll down to the bottom of the “Data” tab and press “Save” again.

    Adding a NetCDF store

Preview the NetCDF layer

  1. Select “Layer Preview” from the menu on the left

  2. Scroll down to find the “cite:O3” entry, and click on the “OpenLayers” link to show a preview of the layer.

  3. Clicking on points will cause the value of “Ozone_concentration” to be shown in a table at the bottom of the map.

    OpenLayers preview of a NetCDF layer

Note

This GeoServer instance has been configured with the NETCDF_DATA_DIR Java system property to allow the publication of NetCDF files in read-only directories.

What next?

This is only the first step on the road to using GeoServer. There is a lot more functionality you can try.