Working With Postgis: in This Module You Will
Working With Postgis: in This Module You Will
Module 3
Working with PostGIS
This module focuses on how to use the PostGIS spatial database with
GeoServer. The reader will begin by walking through the installation process, and
continue on to learn how to load spatial data into PostGIS.
1
MODULE 3: Working with PostGIS
2
MODULE 3: Working with PostGIS
3. On the Welcome screen click Next.
5. On the Installation Options screen accept all the defaults and click
Next.
3
MODULE 3: Working with PostGIS
For security
reasons PostgreSQL
requires a non-
privileged account to
be installed. The
installer will create
one for you. This
account can be
removed later.
4
MODULE 3: Working with PostGIS
5
MODULE 3: Working with PostGIS
6
MODULE 3: Working with PostGIS
7
MODULE 3: Working with PostGIS
8
MODULE 3: Working with PostGIS
9
MODULE 3: Working with PostGIS
10
MODULE 3: Working with PostGIS
11
MODULE 3: Working with PostGIS
12
MODULE 3: Working with PostGIS
13
MODULE 3: Working with PostGIS
6. In the File Explorer navigate to the data directory on the USB drive and
open the buildings.sql file.
The buildings.sql
file contains the SQL
statements to create a
table named roads and
populate it with data.
14
MODULE 3: Working with PostGIS
7. Execute the SQL by clicking the Execute Query button in the toolbar.
15
MODULE 3: Working with PostGIS
16
MODULE 3: Working with PostGIS
4. Select Postgis from the dropdown list and enter “postgis” in the text
box.
17
MODULE 3: Working with PostGIS
6. Click Apply and then Save located in the top left corner of the page.
18
MODULE 3: Working with PostGIS
2. Click New.
19
MODULE 3: Working with PostGIS
5. Generate the bounds for the layer by clicking Generate located on the
middle of the page.
20
MODULE 3: Working with PostGIS
8. View the new layer from the Map Preview and clicking the
topp:buildings link.
21
MODULE 3: Working with PostGIS
22
MODULE 3: Working with PostGIS
sights.shp
sights.shx
sights.dbf
sights.prj
23
MODULE 3: Working with PostGIS
cd Desktop
“C:\Program Files\PostgreSQL\8.2\bin\shp2pgsql.exe”
-s 4326 sights.shp sights > sights.sql
Note the double
quotes “” around the
path to shp2pgsql.
They are necessary
because of the space
in the file path.
shp2pgsql is a
utility program used
to convert a shapefile
into a database table.
It comes with every
PostGIS installation.
“C:\Program Files\PostgreSQL\8.2\bin\psql.exe”
–U postgres postgis < sights.sql
If prompted for a
password remember
that the password is
“postgres”.
psql is a
program used to
interact with a
Postgres database
from the command
line.
24
MODULE 3: Working with PostGIS
7. Using skills learned in the previous section, publish the sights table
created in the previous step.
25