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
?
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.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With