Loading data into a database via the Layer Importer

With the Layer Importer, it is possible not only to publish data to GeoServer with ease, but also to load the data into a database first and then publish the data, all in a single process.


Serving data from a spatial database is usually recommended, due to advantages in concurrent access, editing, and speed. That said, data is often retrieved and transferred in “flat” spatial files such as shapefiles.

Recognizing this, the Layer Importer can perform a two step process during a spatial file import:

  • Load the data into a database
  • Publish the newly-created database tables as layers in GeoServer

All that is required is that the database store be set up in advance, and then be the target of the import.


In this example, we’ll load a single shapefile into a PostGIS database, and then publish that table with GeoServer, but be aware that this process works with any valid spatial file and database store type in GeoServer.

Create a database store

The first step is to add the store that will be the target of the data loading. The database that we will be using must already be created, though it need not be empty.

  1. In the GeoServer web interface, navigate to Data ‣ Stores ‣ Add a new store.

  2. Select the database type that you would like to use..

  3. Enter in the connection parameters.


    Store connection parameters (workspace = import, store = postgres)

  4. Click Save when done.

  5. You will see a list of layers (if any) inside the store. It is not necessary to do anything here, as we’ll move over to the Layer Importer to publish layers.

Import the spatial file

Now with the database store created, we can use the Layer Importer to load data into the database, and then into GeoServer.

  1. Navigate to Data -> Import Data to bring up the Layer Importer.

  2. Select the button for Spatial Files.

  3. In the section titled Configure the data source, enter the path to the spatial file to load.


    As with all Importer operations, this file must be locally accessible to the machine where GeoServer is running.

  4. In the section titled Specify the target for the import, specify the workspace and store that represents the database loaded in the previous step.


    Importer settings to load into a database

  5. Click Next.

  6. The file(s) will be enumerated and the list will be displayed on the next page. As with a normal import process, select the layer(s) you wish to load and then click Import.

At this point, the files will be loaded into the database and then subsequently published as layers in GeoServer.