[GIS] Does PostGIS not work with psql

postgispostgis-1.5postgresql

I have a sql script that creates several tables, a trigger, and a trigger function. All the commands work in pgAdmin when I execute them in the "Query" section. My goal is to put all these commands in a script so that I can set up the database on any machine relatively easily and quickly. When I attempt to run the script through psql, however, I get the following errors on all of the lines where I attempt to use Geography types:

ERROR:  type "geography" does not exist

It doesn't make sense because I can copy and paste the exact same queries into the query editor of pgAdmin and it works just fine. Does psql not support PostGIS? Or maybe just not the most recent version of PostGIS, 1.5.3, which includes the new Geography types? Is there something I can do to fix this?

An example of one of my queries:

CREATE TABLE source_imagery (
    id SERIAL PRIMARY KEY,
    image_type VARCHAR(1000),
    image_path VARCHAR(1000),
    boundary GEOGRAPHY(POLYGON, 4326),
    image_time TIMESTAMP,
    catalog_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Error message:

ERROR:  type "geography" does not exist
LINE 5:     boundary GEOGRAPHY(POLYGON, 4326),
                     ^

Best Answer

If PGAdmin is definitely succeeding at operations involving the geography type, then I can only suggest making sure that psql and PgAdmin are actually connected to the same database. The error reported by psql is from the server, psql is just the messenger. are you specifying a spatially-enabled database when you invoke psql? If not, see http://postgis.net/docs/postgis_installation.html#templatepostgis

Related Question