Loading GIS Data

Once you have created a spatial table, you are ready to upload GIS data to the database. Currently, there are two ways to get data into a PostGIS/PostgreSQL database: using formatted SQL statements or using the Shape file loader/dumper.

Using SQL

If you can convert your data to a text representation, then using formatted SQL might be the easiest way to get your data into PostGIS. As with Oracle and other SQL databases, data can be bulk loaded by piping a large text file full of SQL "INSERT" statements into the SQL terminal monitor.

A data upload file ("roads.sql" for example) might look like this:

INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (1,'LINESTRING(191232 243118,191108 243242)','Jeff Rd');
INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (2,'LINESTRING(189141 244158,189265 244817)','Geordie Rd');
INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (3,'LINESTRING(192783 228138,192612 229814)','Paul St');
INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (4,'LINESTRING(189412 252431,189631 259122)','Graeme Ave');
INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (5,'LINESTRING(190131 224148,190871 228134)','Phil Tce');
INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (6,'LINESTRING(198231 263418,198213 268322)','Dave Cres');

The data file can be piped into PostgreSQL very easily using the "psql" SQL terminal monitor:

psql -d [database] -f roads.sql

Using the Loader

This section to be done.