Introduction to the OpenGeo Suite

Importing data from PostGIS

In this section we’re going load several PostGIS tables simultaneously into GeoServer.

We could easily just follow the same steps we used to load our GeoTIFF, for each table in our PostGIS store; however, that would get a little repetitive.

GeoServer ships with a Layer Importer that streamlines the workflow down to a few steps for multiple tables in a database. The Layer Importer works with database tables and directories of shapefiles.

Essentially, once pointed at its target, the Layer Importer creates a single, common store for the features in that target, pulls them in as individual layers, assigns their properties (Name, SRID, etc) where possible from metadata, and generates a unique style for each layer.

Import From PostGIS store

  1. From the GeoServer Admin page, click on the Import Data link on the left-hand side, under Data.

    ../_images/gs_link_importer.png

    Click this link to go to the Import page

  2. Click on PostGIS to select spatial tables from PostGIS as your data type.

    ../_images/gs_link_importpostgis.png

    Import from data source

  3. Fill out the following form.

    Database

    SuiteWorkshop

    Port

    5432

    Username

    postgres

    Password

    [blank]

    ../_images/gs_importerparams.png

    PostGIS data store import parameters.

  4. Click Next when ready.

  5. This screen asks you to select the layers to import from a list of all of the resources that exist in the store.

    ../_images/gs_importerlayers.png

    Select resources to import from the store.

  6. Ensure that all checkboxes are checked, and click Import Data.

  7. A progress monitor marks the status of the import.

  8. When the process is complete, you are redirected to the Import Results page.

    ../_images/gs_importresults.png

    Import results

    Note

    If the SRS is not populated automatically, check all of the relevant layers and click Declare SRS. The next screen will allow you to select the coordinate system that applies to your data.

That’s about it! In a consolidated number of steps, you have declared a store, and imported and published a handful of layers in GeoServer. This is the recommended approach when importing many layers from PostGIS or a directory of Shapefiles.

Layer Preview

As a final step to our bulk data load, let’s preview some of what we’ve done.

  1. From the list of layers in the Import Results screen, find the countries layer. Click the Go link to the right of the countries entry to open the layer in OpenLayers.

  2. A new tab will open up in your browser, showing your layer inside an OpenLayers application.

    ../_images/gs_previewol.png

    Viewing the published layer in OpenLayers

Note

If you’re wondering where the style/color is coming from, this will be discussed in the Styling Layers in GeoServer section.

  1. Play around with this window. You can use your mouse to zoom and pan, and can also click on the layer features to display attribute information.

Congratulations, your PostGIS data has been successfully published in GeoServer! You now have spatial data on the web!



This Page

About Boundless

Boundless provides commercial open source software for internet mapping and geospatial application development. We are dedicated to the growth and support of open source software.

License

This work is licensed under a Creative Non Commercial-Commons Attribution-Share Alike 3.0 United States License. Feel free to use this material, but we ask that you please retain the Boundless branding, logos and style.

Creative Commons License