There are a variety of ways to load a PostGIS database with spatial data. This section covers the task of loading a database with spatial data via SQL scripts loaded with pgAdmin.
In the Object Browser navigate to Databases ‣ bayarea, and click the SQL Query button in the toolbar.
Selecting a database and executing an SQL query
In the Query window, open the File menu and select Open.
Opening an SQL script
In the File Explorer navigate to the workshop data/bayarea directory and open the bay_area_roads.sql file.
Selecting the bay_area_roads SQL script
The bay_area_roads SQL script
Note
The bay_area_roads.sql file contains the SQL statements to create a table named bay_area_roads and populate it with data.
Warning
It may take a few moments for pgAdmin to load the bay_area_roads script. Be patient.
Execute the SQL by clicking the Execute Query button in the toolbar.
Executing an SQL script
Upon successful query execution the following status message should appear in the Messages panel:
Successful SQL completion
Repeat steps 5 through 7 with the bay_area_transit.sql script
Note
The bay_area_transit.sql creates the tables:
Verify that all the tables are loaded via the pgAdmin Object Browser:
Browsing tables in the bayarea database
Note
It may be necessary to refresh the bayarea database in the object browser before the new tables are visible.
Refreshing the database
At this point the PostGIS database has been created and is loaded with spatial data. The next few sections will focus on connecting to PostGIS with GeoServer and serving the data sets created in this section.