Geoscience Reference
In-Depth Information
TABLE 14.2
Methods for sp Classes
Method
What It Does
[
Select spatial items (points, lines, polygons or rows/cols from a grid) and/or attribute variables
$, $<-, [[, [[<-
Retrieve, set or add attribute table columns
spsample
Sample points from a set of polygons, on a set of lines or from a gridded area
bbox
Get the bounding box
Proj4string
Get or set the projection (coordinate reference system)
coordinates
Set or retrieve coordinates
coerce
Convert from one class to another
over
Combine two different spatial objects
Table 14.2 lists some of the methods provided in the sp package; the most important are undoubtedly
the access and assignment functions $, $<-, [[, [[<-, which permit the Spatial*DataFrame objects
to behave as data.frame objects. This means that visualising relationships between raster and vector
attributes, or fitting a regression model to such attributes, involves no extra steps. One important com-
ponent of sp class objects is the coordinate reference system slot, represented in the form of a PROJ.4
string; it may be set missing but is used in both visualisation and analysis when specified.
Figure 14.3 shows that there were 122 CRAN dependencies on sp in March 2012, and a further
302 suggested sp but did not depend on or import from it. By comparison, when Bivand et al. (2008,
see corresponding figure on p. 5) was published, 23 packages depended on sp , of which 8 were writ-
ten and/or maintained by the topic authors. This may be taken as an indication that the provision of
classes for spatial data has achieved its goals, to make it easier for researchers to get their own work
done without having to reinvent data representations.
In the short time since its publication on CRAN in March 2010 following 16 months in
R-Forge,* the raster package (Hijmans and van Etten 2011) has been adopted by many users.
van Etten and Hijmans (2010) have already published using the package, and undoubtedly many
papers will follow. For many purposes, the abstractions introduced in the package simplify the
SpatialGridDataFrame representation from sp , and because only tiles of the raster, raster
FIGURE 14.3
Dependencies on sp from CRAN packages, March 2012.
* https://r-forge.r-project.org/.
 
Search WWH ::




Custom Search