Postgis-2.0.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
PostGIS 2.0 Manual i PostGIS 2.0 Manual SVN Revision (15183) PostGIS 2.0 Manual ii Contents 1 Introduction 1 1.1 Project Steering Committee . .1 1.2 Contributors Past and Present . .1 1.3 More Information . .3 2 Installation 4 2.1 Short Version . .4 2.2 Requirements . .5 2.3 Getting the Source . .6 2.4 Installation . .6 2.4.1 Configuration . .7 2.4.2 Building . .8 2.4.3 Building PostGIS Extensions and Deploying them . .8 2.4.4 Testing . 10 2.4.5 Installation . 12 2.5 Create a spatially-enabled database on PostgreSQL lower than 9.1 . 13 2.6 Creating a spatial database using EXTENSIONS . 13 2.7 Installing, Upgrading Tiger Geocoder and loading data . 14 2.7.1 Tiger Geocoder Enabling your PostGIS database . 14 2.7.2 Upgrading your Tiger Geocoder Install . 15 2.7.3 Loading Tiger Data . 15 2.8 Create a spatially-enabled database from a template . 15 2.9 Upgrading . 16 2.9.1 Soft upgrade . 16 2.9.1.1 Soft Upgrade Pre 9.1+ or without extensions . 16 2.9.1.2 Soft Upgrade 9.1+ using extensions . 16 2.9.2 Hard upgrade . 17 2.10 Common Problems . 18 2.11 JDBC . 18 2.12 Loader/Dumper . 19 PostGIS 2.0 Manual iii 3 PostGIS Frequently Asked Questions 20 4 Using PostGIS: Data Management and Queries 24 4.1 GIS Objects . 24 4.1.1 OpenGIS WKB and WKT . 24 4.1.2 PostGIS EWKB, EWKT and Canonical Forms . 25 4.1.3 SQL-MM Part 3 . 26 4.2 PostGIS Geography Type . 27 4.2.1 Geography Basics . 27 4.2.2 When to use Geography Data type over Geometry data type . 29 4.2.3 Geography Advanced FAQ . 29 4.3 Using OpenGIS Standards . 29 4.3.1 The SPATIAL_REF_SYS Table and Spatial Reference Systems . 30 4.3.2 The GEOMETRY_COLUMNS VIEW . 31 4.3.3 Creating a Spatial Table . 31 4.3.4 Manually Registering Geometry Columns in geometry_columns . 32 4.3.5 Ensuring OpenGIS compliancy of geometries . 35 4.3.6 Dimensionally Extended 9 Intersection Model (DE-9IM) . 39 4.3.6.1 Theory . 40 4.4 Loading GIS Data . 43 4.4.1 Using SQL . 43 4.4.2 Using the Loader . 43 4.5 Retrieving GIS Data . 45 4.5.1 Using SQL . 45 4.5.2 Using the Dumper . 46 4.6 Building Indexes . 46 4.6.1 GiST Indexes . 47 4.6.2 Using Indexes . 47 4.7 Complex Queries . 48 4.7.1 Taking Advantage of Indexes . 48 4.7.2 Examples of Spatial SQL . 48 5 Raster Data Management, Queries, and Applications 52 5.1 Loading and Creating Rasters . 52 5.1.1 Using raster2pgsql to load rasters . 52 5.1.2 Creating rasters using PostGIS raster functions . 56 5.2 Raster Catalogs . 56 5.2.1 Raster Columns Catalog . 56 5.2.2 Raster Overviews . 57 PostGIS 2.0 Manual iv 5.3 Building Custom Applications with PostGIS Raster . 58 5.3.1 PHP Example Outputting using ST_AsPNG in concert with other raster functions . 58 5.3.2 ASP.NET C# Example Outputting using ST_AsPNG in concert with other raster functions . 59 5.3.3 Java console app that outputs raster query as Image file . 60 5.3.4 Use PLPython to dump out images via SQL . 62 5.3.5 Outputting Rasters with PSQL . 62 6 Using PostGIS Geometry: Building Applications 64 6.1 Using MapServer . 64 6.1.1 Basic Usage . 64 6.1.2 Frequently Asked Questions . 65 6.1.3 Advanced Usage . 66 6.1.4 Examples . 67 6.2 Java Clients (JDBC) . 68 6.3 C Clients (libpq) . 69 6.3.1 Text.