Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostGIS Error: type "geography" does not exist

I just upgraded my development machine to Windows 7 and am therefore reinstalling PostgreSQL and PostGIS. I used the Postgres Plus installer, as recommended on the Postgres website, and followed this tutorial for installation. I created a database using the template_postgis and the application that I am currently developing was able to connect to the database with no problems.

However, my old code is not able to create tables using the PostGIS Geography like it used to. For example, when I try to create the following table:

CREATE TABLE test_area (
    id SERIAL PRIMARY KEY,
    name VARCHAR(1000),
    area GEOGRAPHY(POLYGON, 4326),
    start_time DATE,
    end_time DATE
)

I get the following error:

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

If I look under the database in the Object brower of pgAdmin III, I see a bunch of Geometry functions, so the installation seems to have run correctly. I'm not sure what my problem might be. Is it possible for the installer to only install PostGIS Geometry, but not Geography?

like image 710
Steph Avatar asked Aug 09 '11 18:08

Steph


People also ask

What is PostGIS geography?

The PostGIS "geography" type is a geospatial type that understands coordinates as spherical coordinates, in latitude and longitude. Here is a small table of world airports, loaded into a geography column.

What does PostGIS stand for?

PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL. Docs for latest stable release.


1 Answers

I have experienced this issue before as well, but what helped me was not the answer on the GIS site.

I have Postgresql installed via Homebrew and I also have the Postgresql app installed. As for PostGIS, however, I installed it via Homebrew.

When I encountered this problem, I was running the Postgresql app instead of running it in Terminal, so of course you'd get this PostGIS error because PostGIS was never installed on the Postgresql app. Once I started Postgresql in Terminal, it worked for me.

Update 9/25/2014:

It's possible that you did not create the extension for PostGIS in your database:

$ psql

psql> \c databaseName;

psql> CREATE EXTENSION Postgis;
like image 195
Harry Wang Avatar answered Sep 18 '22 16:09

Harry Wang