Introduction to the OpenGeo Suite

Loading data into PostGIS

This section focuses on the basic task of loading shapefiles into our database using the graphical PostGIS shapefile loading tool, pgShapeloader. PostGIS is supported by a wide variety of libraries and applications, and provides many other options for loading data in a variety of formats.

  1. From the Start Menu, click the pgShapeloader link found in OpenGeo Suite ‣ pgShapeloader.

  2. Click View connection details and enter the following:

    Option

    Value

    Username

    postgres

    Password

    [blank]

    Server Host

    localhost 5432

    Database

    SuiteWorkshop

  3. When finished, click OK to test the connection.

  4. Next, click Add File and navigate to the data directory in the workshop package. Select the following files:

    • cities.shp
    • countries.shp
    • ocean.shp
  5. Next, click to edit each entry’s SRID column, and change every entry to 4326 (from 0).

  6. Finally, click the Import button to launch the import process.

    ../_images/pgshapeloader_main.png

    Loading a shapefile into PostGIS

  7. When all of the files are loaded, go back to pgAdmin and click the Refresh button to update the tree view. You should see your three new tables show up in the Tables section of the tree.

    ../_images/pgadmin_refreshed.png

    pgAdmin view with newly-loaded tables

Bonus: Visualizing PostGIS data

Geometries in PostGIS look a little something like this...

../_images/pg_matrix.png

Geometries in PostGIS

SELECT geom FROM countries ORDER BY geom DESC;

This binary code isn’t readable by humans! So we need help in order to allow us to visualize our PostGIS data. Unfortunately, there is no utility inside PostGIS or pgAdmin themselves to display data. Fortunately, though, there are many other applications that can connect to a PostGIS database, and display and edit data in a more appealing manner.

Installing a fresh GIS client on your workstations is a bit beyond the scope of this workshop, but if you do have something handy you can load this data. We recommend QGIS for desktop-based data viewing.

../_images/pg_udig.png

Vive la France!

If you have a client capable of connecting to PostGIS, go ahead and give it a quick try. Recall the connection parameters from earlier:

Username postgres
Password [blank]
Server Host localhost 5432
Database SuiteWorkshop


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