SESYNC Releases R Package for Working with PostGIS

May 4, 2016
Printer-friendly versionPDF version


Data Scientist

From geotagged social media posts to satellite-based remote sensors, the variety and volume of geodatasets – data items associated with specific spatial coordinates or areas – are rapidly growing, as is their use in socio-environmental systems research. Today, free and open source spatial analysis software offer a level of functionality and efficiency matching that of proprietary Geographical Information Systems (GIS). At SESYNC, we provide tools for and training on how to use the R programming language for spatial data analysis and visualization, and also host a PostGIS server to store larger geodatabases. PostGIS is the spatial extension to the popular open source database system, PostgreSQL. A typical workflow integrating both resources might involve importing a subset of the geodata from PostGIS into R, performing some analysis, and possibly re-exporting the output to the database.

A data table containing both geometries (spatial points, lines or polygons) and hstores (sets of key-value pairs) – Diagram made by Kelly Hondula, SESYNC

Above graphic: A data table containing both geometries (spatial points, lines or polygons) and hstores (sets of key-value pairs) – Diagram courtesy of Kelly Hondula, SESYNC

To simplify data transfer between PostGIS and R, we developed a set of functions that was recently released as a R package on CRAN. These functions automate the conversion between the PostGIS “geometry” data type and the standard spatial data types in R; they can also read and write data in the PostgreSQL “hstore” format, a flexible data type where each table cell can contain multiple named attributes. Example use cases can be found in the accompanying vignette/tutorial.

We plan to update these tools based on user needs, and thus welcome any feedback on current features or potential new features that would be of interest. For more details or to open an issue concerning the software package, please visit our Github site.

The National Socio-Environmental Synthesis Center, funded through an award to the University of Maryland from the National Science Foundation, is a research center dedicated to accelerating data-driven scientific discovery at the interface of human and ecological systems. Visit us online at and follow us on Twitter @SESYNC.

Share: Facebook Icon Twitter Icon Linked Icon