R contributed package "rgdal"

As from release 0.3-5, rgdal depends on contributed package sp from CRAN, and reads and writes supported rasters with spatial references if available to and from sp classes. From this release, it also supports reading OGR vector data with spatial references if available into sp classes. It supercedes both the earlier rgdal package, and the off-CRAN spGDAL and Rmap packages.

Downloading and documentation

The R contributed package rgdal is available from CRAN as a source package for installation on platforms with the full build train and external dependencies. The external dependencies are GDAL and its dependencies. These may also be provided in binary form for some platforms, but to install the source rgdal package, the headers and development libraries will be required. A Windows binary package is provided on CRAN with both rgdal and its dependencies.

This site is only used for development, not for releasing software. Further details are available in the README and README.windows files distributed with the R package, and may be browsed online in the CVS repository. In addition, hints on OSX installation are to be found here.

Documentation is available inside the package, and at CRAN.

GDAL - R bindings to Frank Warmerdam's Geospatial Data Abstraction Library

Package renamed "rgdal" - hosted on SourceForge

From July 2003, the package is hosted on SourceForge. The CVS repository can be viewed and contributions are welcome. A number of releases have been made on SourceForge. The package is based on S4 classes and depends on the pixmap and abind packages.

As of 26 November 2003, rgdal is released on CRAN, and uses configure to install on systems with installed GDAL.

The GDAL home page is here.

More information on R and how to install packages is here.

The original R package by Timothy H. Keitt is here; this runs with GDAL 1.1.7 and R prior to 1.6.0, when major changes in the methods package (a.k.a new-style classes) stopped it working. A modified package ported back to old-style classes that works under R 1.6.2 and GDAL 1.1.7 (also compiling for me against 1.1.8 using #if GDAL_VERSION_NUM < 1180 #else #endif) is here.

Example session with the modified package:

R version 2.9.1 (2009-06-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(rgdal)
Loading required package: sp
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.6.1, released 2009/05/11
Path to GDAL shared files: /usr/local/share/gdal
Loaded PROJ.4 runtime: Rel. 4.6.1, 21 August 2008
Path to PROJ.4 shared files: (autodetected)
> logo <- system.file("pictures/logo.jpg", package="rgdal")[1]
> x <- new("GDALReadOnlyDataset", logo)
> x
An object of class “GDALReadOnlyDataset”
Slot "handle":
<pointer: 0xeee1bb0>

> getDriverLongName(getDriver(x))
> dim(x)
[1] 77 101
> displayDataset(x)

grey image
> GDAL.close(x)
> Rlogo <- system.file("pictures/Rlogo.jpg", package="rgdal")[1]
> y <- new("GDALReadOnlyDataset", Rlogo)
> y
An object of class “GDALReadOnlyDataset”
Slot "handle":
<pointer: 0xef325a0>

> getDriverLongName(getDriver(y))
> dim(y)
[1] 77 101 3
> yy <- RGB2PCT(y, 1:3)
> displayDataset(yy)

colour image
> GDAL.close(yy)
> GDAL.close(y)