Introduction to PostGIS


Contents

1 Introduction

1.1Requirements & Set-up

1.2Spatial Databases

1.3Conventions

1.4Other Downloads

The PostGIS source code is available from:  http://postgis.refractions.net/.
The GEOS source code is available from:  http://geos.refractions.net/.
The Proj4 source code is available from:  http://proj.maptools.org/.
The PgAdmin administration tool is available from:  http://www.pgadmin.org.

2Database Installation

2.1PostgreSQL Installation

Steps:
  1. 1.Double-click the file postgresql-8.2.msi 
  2. 2.Select your language: 
  1. 3.The installer will start up, recommend that you close all Windows programs, and then display the license agreement. 


  1. 4.When the “Installation options” selector comes up, do not enable installation of the PostGIS extension.
The PostGIS Spatial Extension included in the windows installer is often a few versions behind the current stable release. We will install a current PostGIS version separately after completing the PostgreSQL install.

  1. 5.Install PostgreSQL as a service and select the account to run the service under.
Installing PostgreSQL as a service installs it as a windows service so it starts up automatically when your machine is restarted.
  • .Service name – Name associated with PostgreSQL service. 
  • .Account name – User name to run the service under. The default postgres is standard. You can enter an existing account or a new one. If you enter a new account the installer will automatically create an account for you. If you enter an existing account the account must not be an administrator account.
Administrator accounts are not allowed for security reasons. If a hacker were to gain entry to the computer using PostgreSQL they would gain the permissions of account name the service is run under. Ensuring this is a non-administrator account limits the potential harm they can inflict on the system.
  • .Account Domain – This should be the name of your computer.
If your windows system is setup for domain authentication you will need to enter the domain here. However for our purposes the computer name will suffice.
  • .Account password / Verify password – Password associated with the account name (entered twice for verification).
  • .If the user account does not already exist on the computer you will be prompted to create the account.
  • .Depending on the “strength” of the password you entered the following message might appear – Click ‘No’.
  1. 6.Initialize database cluster. This sets up a database cluster with the given connection information.
A database cluster is a group of databases managed by a single PostgreSQL server instance.
  • .Port Number:  Port Number the database cluster is to reside on. 
  • .Addresses:  Check the ‘Accept connection on all addresses, not just localhost’ if you want other machines to be able to access the database from any other machine. Even with this selected you will still have to specifically indicate which hosts or networks you will accept connections from by editing a configuration file. This is covered in the administrative section of the workshop. 
  • .Locale: Select a locale. This will become the default locale of all databases. The C and POSIX locales will cause the system to behave as if it has no locale support. For the purposes of this demonstration we will use the C locale. 
  • .Encoding: Character encoding to use. For this demonstration we will use SQL_ASCII. 
  • .Superuser Name: This username is used to connect to the database. We will use postgres, although it is not recommended that you use the same name/password as the service account.
This username/password is not associated at all with the service account name/password. The service account name and password is the account the PostgreSQL process is executed within and resides as an operating system user. The Superuser Name/Password is used to connect to the database and perform operations on the database.
  • .Password / Password(again): The password associated with the superuser name. Again we will use postgres. 
  • .On selecting ‘Next’ you will be presented with the following information dialog.
  1. 7.The PL/PgSQL language is required for PostGIS, so ensure it is selected.
PL/Perl is handy for Perl programmers who want to write triggers and functions in Perl, but not required by PostGIS.
  1. 8.
    This form allows you to select additional modules to be installed. Ensure Adminpack is selected. The Fuzzy String Match (soundex, etc), and Tsearch2 (full text indexing) modules might come in handy if you work with PostgreSQL enough to become a power user.


    1. 9.That is it for the tough decisions!  Click ‘Next’ to install PostgreSQL.


    PostgreSQL is now installed on your computer!

    2.2PostGIS Installation


    2.3Spatially-Enable PostgreSQL

    2.3.1Enabling PostGIS Without template_postgis

    If your database does not have a template_postgis to use as a database creation template, you can load PostGIS manually, by invoking a pair of SQL scripts that install the PostGIS functions and types.
    • .In PgAdmin, open up the SQL window by clicking the SQL button (the one with the pencil). 
    • .Choose “File  Open…” and navigate to 
    C:\Program Files\PostgreSQL\8.2\share\contrib\lwpostgis.sql
    • .Press the “Run” button. (The green triangle.) The lwpostgis.sql file will execute, loading the PostGIS functions and objects into the “postgis” database. 
    • .Choose “File  Open…” and navigate to  
    C:\Program Files\PostgreSQL\8.2\share\contrib\spatial_ref_sys.sql
    • .Press the “Run” button again. The spatial_ref_sys.sql file will execute, loading the EPSG coordinate reference systems into the PostGIS spatial reference table.  
    The “postgis” database is now set up and ready for data to be loaded. There are a few things that we should remember for other applications:
     Database Name postgis
     User Name  postgres
    Administration Note:  We have created our database as the “postgres” super-user. In a real multi-user system, you will probably have different users with different access privileges to various tables and functions. Setting up users and access permissions can be a complicated DBA exercise, so for workshop purposes we are using the all-powerful super-user.

    Unix Note:  If you install PostgreSQL and PostGIS on a Unix server, you can still use PgAdmin to administer your database. However, when loading the lwpostgis.sql file, you must use the lwpostgis.sql file from your Unix distribution, the one created during the build and install of PostGIS. This is because the lwpostgis.sql file includes references to machine library files that include the spatial functions. The Windows version of the file will not make sense to a Unix machine because the references will not point to the right files.

    3Using PostGIS

    3.1Simple Spatial SQL

Terimakasih Anda telah membaca tentang
Judul: Introduction to PostGIS
Rating: 100% based on 90 ratings. 376 user reviews.
Ditulis Oleh aa
Semoga informasi Introduction to PostGIS bisa memberikan manfaat bagi Anda. Jangan lupa komentar Anda bila ingin bertanya. Sukses untuk kalian

0 komentar:

Post a Comment