Table of Contents for
Web Mapping Illustrated

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Web Mapping Illustrated by Tyler Mitchell Published by O'Reilly Media, Inc., 2005
  1. Web Mapping Illustrated
  2. Cover
  3. Web Mapping Illustrated
  4. A Note Regarding Supplemental Files
  5. Foreword
  6. Preface
  7. Youthful Exploration
  8. The Tools in This Book
  9. What This Book Covers
  10. Organization of This Book
  11. Conventions Used in This Book
  12. Safari Enabled
  13. Comments and Questions
  14. Acknowledgments
  15. 1. Introduction to Digital Mapping
  16. 1.1. The Power of Digital Maps
  17. 1.2. The Difficulties of Making Maps
  18. 1.3. Different Kinds of Web Mapping
  19. 2. Digital Mapping Tasks and Tools
  20. 2.1. Common Mapping Tasks
  21. 2.2. Common Pitfalls, Deadends, and Irritations
  22. 2.3. Identifying the Types of Tasks for a Project
  23. 3. Converting and Viewing Maps
  24. 3.1. Raster and Vector
  25. 3.2. OpenEV
  26. 3.3. MapServer
  27. 3.4. Geospatial Data Abstraction Library (GDAL)
  28. 3.5. OGR Simple Features Library
  29. 3.6. PostGIS
  30. 3.7. Summary of Applications
  31. 4. Installing MapServer
  32. 4.1. How MapServer Applications Operate
  33. 4.2. Walkthrough of the Main Components
  34. 4.3. Installing MapServer
  35. 4.4. Getting Help
  36. 5. Acquiring Map Data
  37. 5.1. Appraising Your Data Needs
  38. 5.2. Acquiring the Data You Need
  39. 6. Analyzing Map Data
  40. 6.1. Downloading the Demonstration Data
  41. 6.2. Installing Data Management Tools: GDAL and FWTools
  42. 6.3. Examining Data Content
  43. 6.4. Summarizing Information Using Other Tools
  44. 7. Converting Map Data
  45. 7.1. Converting Map Data
  46. 7.2. Converting Vector Data
  47. 7.3. Converting Raster Data to Other Formats
  48. 8. Visualizing Mapping Data in a Desktop Program
  49. 8.1. Visualization and Mapping Programs
  50. 8.2. Using OpenEV
  51. 8.3. OpenEV Basics
  52. 9. Create and Edit Personal Map Data
  53. 9.1. Planning Your Map
  54. 9.2. Preprocessing Data Examples
  55. 10. Creating Static Maps
  56. 10.1. MapServer Utilities
  57. 10.2. Sample Uses of the Command-Line Utilities
  58. 10.3. Setting Output Image Formats
  59. 11. Publishing Interactive Maps on the Web
  60. 11.1. Preparing and Testing MapServer
  61. 11.2. Create a Custom Application for a Particular Area
  62. 11.3. Continuing Education
  63. 12. Accessing Maps Through Web Services
  64. 12.1. Web Services for Mapping
  65. 12.2. What Do Web Services for Mapping Do?
  66. 12.3. Using MapServer with Web Services
  67. 12.4. Reference Map Files
  68. 13. Managing a Spatial Database
  69. 13.1. Introducing PostGIS
  70. 13.2. What Is a Spatial Database?
  71. 13.3. Downloading PostGIS Install Packages and Binaries
  72. 13.4. Compiling from Source Code
  73. 13.5. Steps for Setting Up PostGIS
  74. 13.6. Creating a Spatial Database
  75. 13.7. Load Data into the Database
  76. 13.8. Spatial Data Queries
  77. 13.9. Accessing Spatial Data from PostGIS in Other Applications
  78. 14. Custom Programming with MapServer’s MapScript
  79. 14.1. Introducing MapScript
  80. 14.2. Getting MapScript
  81. 14.3. MapScript Objects
  82. 14.4. MapScript Examples
  83. 14.5. Other Resources
  84. 14.6. Parallel MapScript Translations
  85. A. A Brief Introduction to Map Projections
  86. A.1. The Third Spheroid from the Sun
  87. A.2. Using Map Projections with MapServer
  88. A.3. Map Projection Examples
  89. A.4. Using Projections with Other Applications
  90. A.5. References
  91. B. MapServer Reference Guide for Vector Data Access
  92. B.1. Vector Data
  93. B.2. Data Format Guide
  94.  
  95. ESRI Shapefiles (SHP)
  96.  
  97. PostGIS/PostgreSQL Database
  98.  
  99. MapInfo Files (TAB/MID/MIF)
  100.  
  101. Oracle Spatial Database
  102.  
  103. Web Feature Service (WFS)
  104.  
  105. Geography Markup Language Files (GML)
  106.  
  107. VirtualSpatialData (ODBC/OVF)
  108.  
  109. TIGER/Line Files
  110.  
  111. ESRI ArcInfo Coverage Files
  112.  
  113. ESRI ArcSDE Database (SDE)
  114.  
  115. Microstation Design Files (DGN)
  116.  
  117. IHO S-57 Files
  118.  
  119. Spatial Data Transfer Standard Files (SDTS)
  120.  
  121. Inline MapServer Features
  122.  
  123. National Transfer Format Files (NTF)
  124. About the Author
  125. Colophon
  126. Copyright

What Is a Spatial Database?

A database is a tool for storing and accessing tables of information. Traditional databases store information in fields and records (columns and rows or attributes and values). The types of data that fields can hold varies across different types of databases but, generally speaking, they hold numeric and text data. The main feature of a database is that of querying, where you can retrieve information that meets your specific criteria. Relational databases allow you to join information from multiple tables using a common piece of information that is in both tables.

Tip

To learn more about relational database management systems (RDBMS), see http://en.wikipedia.org/wiki/RDBMS.

A spatial database is much the same, but it can also store geographic data. Several databases and GIS products use the term spatial database to mean slightly different things. For example, ESRI’s Spatial Database Engine (SDE) isn’t a spatial database, but is advertised as an interface between client software and a normal database. It allows spatial data to be stored in SDE’s format, in the database. To load and manipulate the spatial data, you need to have an ESRI product or access to an ESRI service.

ESRI’s SDE product isn’t the only option for spatially enabling a database. Despite the limited amount of marketing, there are other databases available that better fit the description of spatial database. Oracle has an extension called Oracle Spatial and IBM has a Spatial Extender for the DB2 database. MySQL database also has a spatial extension. All these are similar to PostGIS; they store and access the spatial data using database tools, without requiring specialized GIS software to access or modify the data.

PostGIS has several features most commercial spatial databases don’t, some of which initially draw people to PostGIS as an enterprise spatial database management system. PostGIS is actively developed and supported. Support for PostGIS is built into an increasing number of applications including MapServer, JUMP, QGIS, FME, and more. There are extensive functions for interacting with spatial data, without needing a GIS client application. This has inspired many to use PostGIS.

PostGIS can be considered an advanced spatial database because it has the ability to both store and manipulate spatial data. PostGIS isn’t simply a data storage repository, but also an environment for interacting with spatial data. The OGC has created a specification for storing and querying spatial data in an SQL database—the Simple Features Specification for SQL (SFSQL). OGC specifications aren’t just nice to have; they are becoming an integral requirement for geospatial data interoperability. When sharing data or enabling open access to geospatial information is required, these open standards become critical.

PostGIS has one of the most robust implementations of the SFSQL specification, according to the OGC resources page at http://www.opengeospatial.org/resources/?page=products. Because PostGIS implements all SFSQL specifications, you can access standardized functions without proprietary twists and turns over the lifespan of your projects. Some other applications only implement subsets of the SFSQL specification.

The way geographic data is presented in PostGIS (as returned in a query) is very intuitive, as you will see from the examples in this chapter. You can get access to coordinates of spatial features through a variety of methods, depending on your need. You can query from a command-line SQL tool or view them graphically with mapping software. Either way, you aren’t bound to using proprietary tools to get access to your information.

Server-Based GIS

PostgreSQL is a database server product. When requests are made to the database, the server processes the request, prepares the data, and returns the results to your application. All the heavy-duty work is done on the server, and only the results are sent back to you. For many applications, this is critical. Even with the horsepower of modern computers, most PCs aren’t designed to handle the intense workload of database queries. If all the data had to be sent across a network to be processed by your application on the user’s machine, the network and client program would be a major performance bottleneck.

The same problem exists for GIS and spatial data management. Many, if not most, GIS desktop applications have a strong reliance on the user’s computer. This may be fine for normal mapping processes (though mapping complex features can be very slow), but when you consider doing more advanced spatial analysis, problems appear.

Consider this example. You have a large number of polygons to merge together based on some attribute. The GIS program loads the required polygons into your computer’s memory or into a temporary file. This alone can be a major bottleneck, because it sucks down large amounts of data over the network. However, when the process of merging polygons begins, it isn’t uncommon to see major memory and processor used, not to mention major hard-disk activity while churning through all the data.

Another issue is that the desktop GIS program may not have the capability to do the analysis you need. Your options are usually to purchase an add-on software component or use another application to process the data. The same process as in the previous example occurs: there’s heavy data copying and processing on the PC, and you often need to convert the data to another format.

PostGIS takes advantage of the server-based database by making an extensive set of GIS functions available on the server. One way to think of this is that PostGIS includes the spatial data storage and also spatial data-manipulation capabilities usually found only in desktop GIS products. This significantly reduces the requirements of client applications by taking advantage of the server’s capabilities. This is a key strength of PostGIS.

Future GIS desktop applications will be little more than products for visualization, with the GIS functionality happening in the spatial database. There is already some movement toward this model. With the openly accessible capabilities of PostGIS, application developers can build spatial capabilities into their database applications right now.

PostGIS is an extension of the PostgreSQL database, so having a standard PostgreSQL installation is the place to start. A custom compiled version of PostgreSQL isn’t required to use PostGIS. PostGIS consists of three components:

PostGIS libraries

The core library is libpostgis.so or libpostgis.dll on Windows. This library is the interface between PostgreSQL capabilities and the spatial abilities of PostGIS.

PostGIS script for functions and types

There is one main script that loads in the hundreds of PostGIS specific functions and types: postgis.sql. Newer versions of PostGIS don’t have a postgis.sql file; instead you use a file called lwpostgis.sql.

Optional script for project support

An optional script called spatial_ref_sys.sql is often loaded that lets you use spatial reference systems or projections with PostGIS data.

The scripts are platform-independent, so getting the libraries you need is the hardest part. You may want to compile your own PostGIS extension to include custom capabilities, though this is increasingly unnecessary.

Documentation from the PostGIS web site is a good starting point for everyone, and walks you through more detail than presented here. Look for the online PostGIS documentation at http://postgis.refractions.net/docs/.

Warning

The examples in this chapter are based on PostgreSQL Version 7.4 and PostGIS Version 0.8. At the time of writing PostgreSQL is at Version 8.0 and PostGIS 1.0 is about to be released. More recent versions are available, but there are still some problems being ironed out. Some of the examples will show slightly different results if you use the newer versions.