Handling Spatial Data in R_part_1
Handling Spatial Data in R_part_1
The key intuition underlying the development of the classes and methods in
the sp package, and its closer dependent packages, is that users approaching
R with experience of GIS will want to see ‘layers’, ‘coverages’, ‘rasters’, or
‘geometries’. Seen from this point of view, sp classes should be reasonably
familiar, appearing to be well-known data models. On the other hand, for sta-
tistician users of R, ‘everything’ is a data.frame, a rectangular table with rows
of observations on columns of variables. To permit the two disparate groups
of users to play together happily, classes have grown that look like GIS data
models to GIS and other spatial data people, and look and behave like data
frames from the point of view of applied statisticians and other data analysts.
This part of the book describes the classes and methods of the sp package,
and in doing so also provides a practical guide to the internal structure of
many GIS data models, as R permits the user to get as close as desired to the
data. However, users will not often need to know more than that of Chap. 4 to
read in their data and start work. Visualisation is covered in Chap. 3, and so a
statistician receiving a well-organised set of data from a collaborator may even
be able to start making maps in two lines of code, one to read the data and
one to plot the variable of interest using lattice graphics. Note that coloured
versions of figures may be found on the book website together with complete
code examples, data sets, and other support material.
If life was always so convenient, this part of the book could be much shorter
than it is. But combining spatial data from different sources often means
that much more insight is needed into the data models involved. The data
models themselves are described in Chap. 2, and methods for handling and
combining them are covered in Chap. 5. Keeping track of which observation
belongs to which geometry is also discussed here, seen from the GIS side as
feature identifiers, and row names from the data frame side. In addition to
data import and export, Chap. 4 also describes the use and transformation of
coordinate reference systems for sp classes, and integration of the open source
GRASS GIS and R. Finally, Chap. 6 explains how the methods and classes
introduced in Chap. 2 can be extended to suit one’s own needs.