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?
-
1Did you run "create extension postgis;" within your db after you installed the packages?Matte– Matte2017-03-27 13:29:22 +00:00Commented Mar 27, 2017 at 13:29
-
These instructions have been rock solid for me for a few years - they include all the steps you're asking about: trac.osgeo.org/postgis/wiki/UsersWikiPostGIS22UbuntuPGSQL95AptInactivated Account– Inactivated Account2017-03-27 14:34:14 +00:00Commented Mar 27, 2017 at 14:34
-
I updated the instructions for 9.6 and PostGIS 2.3 - I was testing on xenial. trac.osgeo.org/postgis/wiki/UsersWikiPostGIS23UbuntuPGSQL96AptRegina Obe– Regina Obe2017-03-27 15:16:49 +00:00Commented Mar 27, 2017 at 15:16
Add a comment
|
1 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.
-
You can also use shp2pgsql. You'll need to apt-get install postgis to get that since they have the client command line stuff like shp2pgsql and raster2pgsql in that package instead of as part of the regular postgresql postgis server packageRegina Obe– Regina Obe2017-03-27 15:19:05 +00:00Commented Mar 27, 2017 at 15:19