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.

At present, a Windows binary package of release 0.2-7 is available from Professor Brian D. Ripley's repository. This includes the referenced GDAL components in a local gdal12.dll built by Prof. Ripley.

A Windows binary package of release 0.3-5 is available for download from this sourceforge site, but its placing will be changed when agreed. In order to install the R Windows binary rgdal package, you should first have installed GDAL/OGR with all of their dependencies needed for the data you need to access.

Installing FWTools is a convenient way to get started (but will be limited to the - extensive - range of drivers built into the binary package).

Setting the FWTools bin/ directory in the PATH environmental variable is essential, as is setting GDAL_DATA to the appropriate value. Without the FWTools bin/ directory in your PATH, rgdal will not load, but the error messages do tell you what is missing. An informative error message is also displayed if GDAL_DATA is not set correctly.

The R Windows binary rgdal package is built against an FWTools Windows binary, using VC++.

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. Work is ongoing with Hisaji Ono to release a portable Windows binary package, based on an MSYS/MinGW compilation of 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 : Copyright 2003, The R Foundation for Statistical Computing
Version 1.8.1 Patched (2003-11-22), ISBN 3-900051-00-3

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.

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

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

> library(rgdal)
Geospatial Data Abstraction Library extensions to R successfully loaded
> logo <- system.file("pictures/logo.jpg", package="rgdal")[1]
> x <- new("GDALReadOnlyDataset", logo)
> x
An object of class "GDALReadOnlyDataset"
Slot "handle":
<pointer: 0x8e251c0>
> getDriverLongName(getDriver(x))
[1] "JPEG JFIF"
> xGrey <- getPixmapGDAL(x)
Loading required package: pixmap
> xGrey
Pixmap image
Type : pixmapGrey
Size : 77x101
Resolution : 1x1
Bounding box : 0 0 101 77

> plot(xGrey)


grey image
> xCm <- getPixmapGDAL(x, col=cm.colors)
> xCm
Pixmap image
Type : pixmapIndexed
Size : 77x101
Resolution : 1x1
Bounding box : 0 0 101 77
Nr. of colors : 7777 of 256

> plot(xCm)


cm image
> GDAL.close(x)
Closing GDAL dataset handle 0x957e000... destroyed ... done.
> Rlogo <- system.file("pictures/Rlogo.jpg", package="rgdal")[1]
> y <- new("GDALReadOnlyDataset", Rlogo)
> yRGB <- getPixmapGDAL(y)
Loading required package: abind
> yRGB
Pixmap image
Type : pixmapRGB
Size : 77x101
Resolution : 1x1
Bounding box : 0 0 101 77

> plot(yRGB)


colour image
> GDAL.close(y)
Closing GDAL dataset handle 0x8e4fcd0... destroyed ... done.



SourceForge.net Logo