Geoscience Reference
In-Depth Information
support to existing GIS formats to store the attributes in lieu of the legacy dBase file
format (DBF files), but they also provide the facility to simultaneously store both
the geometries and attributes. There are a wide number of systems, such as PostGIS,
Spatialite, MSSQL and ORACLE Spatial that are considered to be spatially enabled
extensions of their underlying databases. It is beyond the scope of this topic to treat
all of the different types of spatial databases. For the purposes of the subsequent
examples and case studies, we focus primarily on Spatialite, but we provide some
brief explanations of how to use OGR to access PostGIS tables. Nonetheless, it is
important to note that many of the queries that are presented for Spatialite can also
be adapted to other spatial databases.
2.7.1 PostGIS
PostGIS is an extension to the PostgreSQL database that can store vector data and
also provides a series of spatial functions that can be used on the database. In most
cases, the GDAL binaries are pre-compiled with PostGIS support, but if not it is pos-
sible to compile GDAL by passing the correct paths to PostgreSQL ( pg_config ).
Accessing PostGIS tables is done by specifying a database connection string, e.g.
PG::"dbname='databasename' host='addr' port='5432' user
='x' password='y'" . This connection string is used with OGR commands.
For instance, if we would like to return summary information regarding a PostGIS
database, including tables and schema it can be done as follows:
ogrinfo PG:"dbname='databasename' host='addr' port='5432'
user='x' password='y'"
2.7.2 Spatialite
Spatialite is a library that provides spatial SQL functionality to the SQLite data-
base. 7 It can store vector geometries and allows for vector operations, including
queries using spatial functions to be performed within the files in the database.
The spatial functions follow the specifications defined by the Open Geospatial Con-
sortium, specifically the OGCSimple Feature Specification (OGC-SFS). 8 The under-
lying SQLite database supports the SQL92 standard. For these reasons, it sharesmany
similarities with PostGIS and Oracle Spatial, but differs in that the database, SQL
7 http://www.sqlite.org
8 http://www.opengeospatial.org/standards/sfs
 
 
Search WWH ::




Custom Search