Spatial data and Drupal 7

This article gives an overview of the management of spatial data with Drupal and briefly describes the components of our implementation.

This article gives an overview of the management of spatial data with Drupal and briefly describes the components of our implementation. A look at the list of over 100 Drupal modules in the category "Location" shows how widespread the requirement is to use spatial data in Drupal. With Drupal being a moving target, particularly due to the development of the Fields API, conditions have changed. The following text describes the management of spatial data in three sections, as they are depicted as green boxes in the diagram.

Geodaten und Drupal

Storing spatial data with PostGIS

In principle one must distinguish whether spatial data is stored with specific spatial data types or with simple numbers or plain text (WKT) in the database. Drupal modules such as Geolocation for points and Geofield are already quite mature and actively maintained, but fall into the last category. On the other hand the use of specific spatial data types was previously possible only with the Geo module, whose development, however, stood still for a year and is therefore not yet available for Drupal 7.

Based on the Fields API we have developed a Drupal module that makes the PostGIS spatial geometry type available as fields for content types. Together with the Drupal module for OpenLayers users of Drupal sites can thus easily edit spatial data stored in a PostGIS database. For now the module is available as a sandbox project on

Reading spatial data with GeoServer

The usual solution to query custom data and display results in Drupal is the Views module. However access to larger spatial datasets will be limited and complex spatial data formats will require a lot of development work. For these reasons we decided to read spatial data from our PostGIS database not through Drupal but with GeoServer. With SQL views, that recently arrived in version 2.1, spatial data can be queried and combined with other data managed by Drupal quite flexibly. In combination with GeoWebCache spatial data is accessible in a variety of formats with high performance.

So far, we only use the REST API of GeoWebCache to generate tiles when content changes. However the RESTful configuration of GeoServer has much potential to automate complex configuration steps. A separate Drupal module for this task would be definitely useful.

Viewing and editing spatial data with OpenLayers

In the end, the user should be able to display and edit spatial data. The OpenLayers module offers extensive configuration options to create maps with different layers and functions. The maps can then be incorporated into the PostGIS module mentioned above or into your own themes. In addition, with so-called behaviors additional map features can be easily implemented and make editing complex spatial data in the browser possible.