[GIS] How to install PostGIS extension for PostgreSQL database under Ubuntu

postgisUbuntu

I am quite a newbie in using Postgres under Ubuntu.
I have created a PostgreSQL database and now want to install the PostGIS extension for it so that I can import shapefiles and use the PostGIS commands.
PostGIS is installed. I use the bash shell. Can somebody give me advice?

Best Answer

PostGIS is installed as an Extension to each Database.

Once you have created a database,

psql -c "CREATE DATABASE Your_Database_Name;"

you can install Extensions.

psql -d "Your_Database_Name" -c "CREATE EXTENSION postgis;"

(or)

psql -d "Your_Database_Name" [Enter]

Your_Database_Name=# CREATE EXTENSION postgis;

Then you can use ogr2ogr to push Shapefiles to the database, or run the PostGIS functions in your database.