Using PostGIS to Handle Geospatial Data as Vectors and Rasters

Date: 2016-09-14
Time: 16:00 - 16:50
Room: Ft. Worth 2
Level: Intermediate

Introduction With the growing amount of geo-located data as well as mapping applications that rely on it, the need for reliable storage, display and analysis of map data is greater than ever. Recent updates in Postgre’s geospatial database extension PostGIS allow for simple ways to perform geographic searches, geo-located data conversion and transformation as well as add basic raster support to an application. This presentation will go into the usage and application of a few of PostGIS’s most useful features as they pertain to storing, displaying and analyzing map data.

Getting data to PosgreSQL The first step is storing geo-located data in the database. Geo-located data may be imported from and exported to common file types such as CSV and SHP. Shp2psql allows data from a shapefile to be imported into the database as a geography type with valid projection settings as defined by the .prj file. Similarly psql2shp allows the result of a database query to be exported to a shape file with appropriate projection files. A short SQL script can be used to do the same with geo-located CSV files. Once loaded the data’s projection can be normalized or otherwise adjusted by setting the SRID using st_transform.

Vector Searching Data can be queried using standard SQL searches. Not only does PostGIS allow for meta-data searches, but also geographic searches including intersection and nearest neighbor. Once a search condition is applied, the output polygons can once again be manipulated through the use of translations in order to get the data into the ideal form for the client application.

Vector Display Often, the source dataset has a much higher resolution than is appropriate for the database and display. Because of performance limitations, web mapping applications are frequently limited on the size and number of vertices a polygon or group of polygons may have. Thus it is often necessary to reduce the resolution of geometry. There are several built in functions that allow a user to do just that.

Raster Display In some cases, however such vector reductions do not reduce the vertex count by enough to keep the web server running quickly. For static, unchanging data, rasterization may be a suitable alternative. PostGIS allows geographic data to be converted from vector to rasterize representations. Using the st_intersecton on envelopes and a tile canvas it is possible to generate grid aligned tiles that may be used to display unchanging data in the form of an exported raster maps. The output is a grid of images such as PNG.


Dylan Herron