PostGIS2.0 has been released, which is very exciting. PostGIS1.5.4 is integrated in 12.04. If you want to use some new features, you have to make the upgrade option. We use the release package of the sharpie project team for deployment. First, uninstall the original postgis and postgresql-9.1-postgis package. Sudodpkg -- purgepostgispostgresql-9.1-postgis then, add the corresponding rep
PostGIS 2.0 has been released and is very exciting. PostGIS 1.5.4 is integrated in 12.04. If you want to use some new features, you have to make the upgrade option. We use the release package of the sharpie project team for deployment.
First, uninstall the original postgis and postgresql-9.1-postgis package.
Sudo dpkg -- purge postgis postgresql-9.1-postgis
Then, add the corresponding repository and install PostGIS.
Sudo apt-add-repository ppa: sharpie/for-science # To get GEOS 3.3.2
Sudo apt-add-repository ppa: sharpie/postgis-nightly
Sudo apt-get update
Sudo apt-get install postgresql-9.1-postgis
Next, create a template library.
Createdb-E UTF8 template_postgis
Createlang-d template_postgis plpgsql
Psql-d postgres-c "UPDATE pg_database SET datistemplate = 'true' WHERE datname = 'template _ postgis '"
Psql-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/postgis. sqlpsql-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/buy-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/postgis_comments.sqlpsql- d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/rtpostgis. sqlpsql-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/raster_comments.sqlpsql-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/topology. sqlpsql-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/topology_comments.sqlpsql-d template_postgis-f/usr/share/postgresql/9.1/contrib/postgis-2.1/legacy. SQL
Finally, you can use the template to create a database.
Creatdb mydb-T template_postgis
References:
1. Deployment content reference
The original content is as follows:
PostGIS 2.0 is out and the awesomness continues! You can install PostGIS 2.0 on Ubuntu using packages which is exactly what I am going to show you here. Read on for details on how to get up and running and do your first simple raster analysis!
Note: You shoshould make good backups first!
Before we begin, you shocould uninstall your existing postgis packages:
Sudo dpkg -- purge postgis postgresql-9.1-postgisThen add a new repository and install PostGIS from there (based on this post ):
Sudo apt-add-repository ppa: sharpie/for-science # To get GEOS 3.3.2
Sudo apt-add-repository ppa: sharpie/postgis-nightly
Sudo apt-get update
Sudo apt-get install postgresql-9.1-postgisNext we shoshould create a new template database (optional but recommended ).
Createdb-E UTF8 template_postgis2
Createlang-d template_postgis2 plpgsql
Psql-d postgres-c "UPDATE pg_database SET datistemplate = 'true' WHERE datname = 'template _ postgis2 '"
Psql-d template_postgis2-f/usr/share/postgresql/9.1/contrib/postgis-2.0/postgis. SQL
Psql-d template_postgis2-f/usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys. SQL
Psql-d template_postgis2-f/usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis. SQL
Psql-d template_postgis2-c "grant all on geometry_columns to public ;"
Psql-d template_postgis2-c "grant all on geography_columns to public ;"
Psql-d template_postgis2-c "grant all on spatial_ref_sys to public ;"
Createdb training-T template_postgis2Ok now we can load a raster (see sample data download below ):
Raster2pgsql-s 4326 srtm_4326.tif | psql training
Shp2pgsql-s 4326-d-g geom-I places. shp places | psql trainingGood-now our spatial database is ready to use-and has raster support! Here is a nice example of what you can do. The query looks up the altitude from the SRTM raster for each place listed using the ST_Value function:
Select ST_Value (rast, geom, true) from places, srtm_4326; It shoshould produce something like this:
Further reading: A really good place to start is the Boston GIS cheatsheets-I am really looking forward to keep ing all the new features that are available in PostGIS 2.0, thanks to all those involved in building it!
Sample data for the example listed
---------------------------------------------------------------------------
2. Instructions for creating a spatial database see http://postgis.refractions.net/documentation/manual-2.0/postgis_installation.html#id2801293