Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-foss4g/creating_db.rst @ 11

Revision 1, 4.9 KB checked in by djay, 13 years ago (diff)

Initial import of the svn tree

Section 3: Creating a Spatial Database

The Dashboard and PgAdmin

The "Dashboard" is the central application to access all portions of the OpenGeo Suite.

When you first start the dashboard, it provides a reminder about the default password for accessing GeoServer.

./screenshots/dashboard_01.png

Note

The PostGIS database has been installed with unrestricted access for local users (users connecting from the same machine as the database is running). That means that it will accept any password you provide. If you need to connect from a remote computer, the password for the postgres user has been set to postgres.

For this workshop, we will be using the entries under the "PostGIS" section of the Dashboard almost exclusively.

  1. First, we need to start up PostGIS. Click the green Start button at the top right corner of the Dashboard.

  2. The first time the Suite starts, it initializes a data area and sets up template databases. This can take a couple minutes. Once the Suite has started, you can click the Manage option under the PostGIS component to start the pgAdmin utility.

    ./screenshots/dashboard_02.png

    Note

    PostgreSQL has a number of administrative front-ends. The primary is psql a command-line tool for entering SQL queries. Another popular PostgreSQL front-end is the free and open source graphical tool pgAdmin. All queries done in pgAdmin can also be done on the command line with psql.

  3. If this is the first time you have run pgAdmin, you should have a server entry for PostGIS (localhost:54321) already configured in pgAdmin. Double click the entry, and enter anything you like at the password prompt to connect to the database.

    ./screenshots/pgadmin_01.png

    Note

    If you have a previous installation of PgAdmin on your computer, you will not have an entry for (localhost:54321). You will need to create a new connection. Go to File > Add Server, and register a new server at localhost and port 54321 (note the non-standard port number) in order to connect to the PostGIS bundled with the OpenGeo Suite.

Creating a Database

PostgreSQL has the notion of a template database that can be used to initialize a new database. The new database automatically gets a copy of everything from the template. When you installed PostGIS, a spatially enabled database called template_postgis was created. If we use template_postgis as a template when creating our new database, the new database will be spatially enabled.

  1. Open the Databases tree item and have a look at the available databases. The postgres database is the user database for the default postgres user and is not too interesting to us. The template_postgis database is what we are going to use to create spatial databases.

  2. Right-click on the Databases item and select New Database.

    ./screenshots/pgadmin_02.png

    Note

    If you receive an error indicating that the source database (template_postgis) is being accessed by other users, this is likely because you still have it selected. Right-click on the PostGIS (localhost:54321) item and select Disconnect. Double-click the same item to reconnect and try again.

  3. Fill in the New Database form as shown below and click OK.

    Name

    nyc

    Owner

    postgres

    Encoding

    UTF8

    Template

    template_postgis

    ./screenshots/pgadmin_03.png
  4. Select the new nyc database and open it up to display the tree of objects. You'll see the public schema, and under that a couple of PostGIS-specific metadata tables -- geometry_columns and spatial_ref_sys.

    ./screenshots/pgadmin_04.png
  5. Click on the SQL query button indicated below (or go to Tools > Query Tool).

    ./screenshots/pgadmin_05.png
  6. Enter the following query into the query text field:

    SELECT postgis_full_version();
    

    Note

    This is our first SQL query. postgis_full_version() is management function that returns version and build configuration.

  7. Click the Play button in the toolbar (or press F5) to "Execute the query." The query will return the following string, confirming that PostGIS is properly enabled in the database.

    ./screenshots/pgadmin_06.png

You have successfully created a PostGIS spatial database!!

Function List

PostGIS_Full_Version: Reports full postgis version and build configuration info.

Note: See TracBrowser for help on using the repository browser.