Azhar's profileSoftware Testing an Art ...PhotosBlogListsMore ![]() | Help |
|
February 28 Installation of PostGISInstallation of PostGIS
*************************************
Table of Contents PostGIS has the following requirements for building and usage:
The PostGIS module is a extension to the PostgreSQL backend server. As such, PostGIS 1.3.3SVN requires full PostgreSQL server headers access in order to compile. The PostgreSQL source code is available at http://www.postgresql.org. PostGIS 1.3.3SVN can be built against PostgreSQL versions 7.2.0 or higher. Earlier versions of PostgreSQL are not supported.
Some packaged distributions of PostGIS (in particular the Win32 installers for PostGIS >= 1.1.5) load the PostGIS functions into a template database called template_postgis. If the template_postgis database exists in your PostgreSQL installation then it is possible for users and/or applications to create spatially-enabled databases using a single command. Note that in both cases, the database user must have been granted the privilege to create new databases. From the shell: # createdb -T template_postgis my_spatial_db From SQL: postgres=# CREATE DATABASE my_spatial_db TEMPLATE=template_postgis Upgrading existing spatial databases can be tricky as it requires replacement or introduction of new PostGIS object definitions. Unfortunately not all definitions can be easily replaced in a live database, so sometimes your best bet is a dump/reload process. PostGIS provides a SOFT UPGRADE procedure for minor or bugfix releases, and an HARD UPGRADE procedure for major releases. Before attempting to upgrade postgis, it is always worth to backup your data. If you use the -Fc flag to pg_dump you will always be able to restore the dump with an HARD UPGRADE. Soft upgrade consists of sourcing the lwpostgis_upgrade.sql script in your spatial database: $ psql -f lwpostgis_upgrade.sql -d your_spatial_database If a soft upgrade is not possible the script will abort and you will be warned about HARD UPGRADE being required, so do not hesitate to try a soft upgrade first. NoteIf you can't find the lwpostgis_upgrade.sql file you are probably using a version prior to 1.1 and must generate that file by yourself. This is done with the following command: $ utils/postgis_proc_upgrade.pl lwpostgis.sql > lwpostgis_upgrade.sql By HARD UPGRADE we intend full dump/reload of postgis-enabled databases. You need an HARD UPGRADE when postgis objects' internal storage changes or when SOFT UPGRADE is not possible. The Release Notes appendix reports for each version whether you need a dump/reload (HARD UPGRADE) to upgrade. PostGIS provides an utility script to restore a dump produced with the pg_dump -Fc command. It is experimental so redirecting its output to a file will help in case of problems. The procedure is as follow: Create a "custom-format" dump of the database you want to upgrade (let's call it "olddb") $ pg_dump -Fc olddb > olddb.dump Restore the dump contextually upgrading postgis into a new database. The new database doesn't have to exist. postgis_restore accepts createdb parameters after the dump file name, and that can for instance be used if you are using a non-default character encoding for your database. Let's call it "newdb", with UNICODE as the character encoding: $ sh utils/postgis_restore.pl lwpostgis.sql newdb olddb.dump -E=UNICODE > restore.log Check that all restored dump objects really had to be restored from dump and do not conflict with the ones defined in lwpostgis.sql $ grep ^KEEPING restore.log | less If upgrading from PostgreSQL < 8.0 to >= 8.0 you might want to drop the attrelid, varattnum and stats columns in the geometry_columns table, which are no-more needed. Keeping them won't hurt. DROPPING THEM WHEN REALLY NEEDED WILL DO HURT ! $ psql newdb -c "ALTER TABLE geometry_columns DROP attrelid" $ psql newdb -c "ALTER TABLE geometry_columns DROP varattnum" $ psql newdb -c "ALTER TABLE geometry_columns DROP stats" spatial_ref_sys table is restore from the dump, to ensure your custom additions are kept, but the distributed one might contain modification so you should backup your entries, drop the table and source the new one. If you did make additions we assume you know how to backup them before upgrading the table. Replace of it with the new one is done like this: $ psql newdb newdb=> drop spatial_ref_sys; DROP newdb=> \i spatial_ref_sys.sql There are several things to check when your installation or upgrade doesn't go as you expected.
Also check that you have made any necessary changes to the top of the Makefile.config. This includes:
The JDBC extensions provide Java objects corresponding to the internal PostGIS types. These objects can be used to write Java clients which query the PostGIS database and draw or do calculations on the GIS data in PostGIS.
The data loader and dumper are built and installed automatically as part of the PostGIS build. To build and install them manually: # cd postgis-1.3.3SVN/loader # make # make install The loader is called shp2pgsql and converts ESRI Shape files into SQL suitable for loading in PostGIS/PostgreSQL. The dumper is called pgsql2shp and converts PostGIS tables (or queries) into ESRI Shape files. For more verbose documentation, see the online help, and the manual pages. TrackbacksThe trackback URL for this entry is: http://rajaazharsatti.spaces.live.com/blog/cns!72E261DDAE567C1E!251.trak Weblogs that reference this entry
|
|
|