An abstract class from which useful spatial classes are derived

Spatial(bbox, proj4string = CRS(as.character(NA)))
# S3 method for class 'Spatial'
subset(x, subset, select, drop = FALSE, ...)

Objects from the Class

are never to be generated; only derived classes can be meaningful

Slots

bbox:

Object of class "matrix"; 2-column matrix holding the minimum in first and maximum in second column for the x-coordinate (first row), y-coordinate (second row) and optionally, for points and grids only, further coordinates. The constructed Spatial object will be invalid if any bbox values are NA or infinite. The column names must be c("min", "max")

proj4string:

Object of class "CRS". The name of this slot was chosen to reflect the use of Proj.4 strings to represent coordinate reference systems (CRS). The slot name will continue to be used, but as PROJ >= 6 and GDAL >= 3 are taken into use for reading files and for projection and transformation, the Proj.4 string CRS representation is being supplemented by a WKT2 (2019) representation. The reason for the modification is that important keys in the Proj.4 string representation are being deprecated in PROJ >= 6 and GDAL >= 3. Legacy "CRS" objects hold only a valid Proj.4 string, which can be used for unprojecting or reprojecting coordinates; it is initialised to NA. If the "CRS" object is instantiated using CRS() with rgdal using PROJ >= 6 and GDAL >= 3, the object may also have a WKT2 (2019) string carried as a comment. Non-NA strings may be checked for validity in the rgdal package, but attempts to assign a string containing "longlat" to data extending beyond longitude [-180, 360] or lattitude [-90, 90] will be stopped or warned, use set_ll_warn to warn rather than stop, and set_ll_TOL to change the default tolerance for the range exceedance tests.

Methods

bbox

signature(obj = "Spatial"): retrieves the bbox element

dimensions

signature(obj = "Spatial"): retrieves the number of spatial dimensions spanned

gridded

signature(obj = "Spatial"): logical, tells whether the data is on a regular spatial grid

plot

signature(x = "Spatial", y = "missing"): plot method for spatial objects; does nothing but setting up a plotting region choosing a suitable aspect if not given(see below), colouring the plot background using either a bg= argument or par("bg"), and possibly drawing axes.

summary

signature(object = "Spatial"): summarize object

$

retrieves attribute column

$<-

sets or replaces attribute column, or promote a geometry-only object to an object having an attribute

rebuild_CRS

rebuild a CRS object, usually used to add a WKT comment with PROJ >= 6 and GDAL >= 3

Arguments

bbox

a bounding box matrix

proj4string

a CRS object

x

object of class Spatial

subset

see subset.data.frame

select

see subset.data.frame

drop

see subset.data.frame

...

passed through

plot method arguments

The plot method for “Spatial” objects takes the following arguments:

x

object of class Spatial

xlim

default NULL; the x limits (x1, x2) of the plot

ylim

default NULL; the y limits of the plot

asp

default NA; the y/x aspect ratio

axes

default FALSE; a logical value indicating whether both axes should be drawn

bg

default par("bg"); colour to be used for the background of the device region

xaxs

The style of axis interval calculation to be used for the x-axis

yaxs

The style of axis interval calculation to be used for the y-axis

lab

A numerical vector of the form c(x, y, len) which modifies the default way that axes are annotated

setParUsrBB

default FALSE; set the par “usr” bounding box; see below

bgMap

object of class ggmap, or returned by function RgoogleMaps::GetMap

expandBB

numeric; factor to expand the plotting region default: bbox(x) with on each side (1=below, 2=left, 3=above and 4=right); defaults to c(0,0,0,0); setting xlim or ylim overrides this.

...

passed through

Author

r-spatial team; Edzer Pebesma, edzer.pebesma@uni-muenster.de Roger Bivand, Barry Rowlingson, Virgilio G\'omez-Rubio

Note

The default aspect for map plots is 1; if however data are not projected (coordinates are longlat), the aspect is by default set to 1/cos(My * pi)/180) with My the y coordinate of the middle of the map (the mean of ylim, which defaults to the y range of bounding box).

The argument setParUsrBB may be used to pass the logical value TRUE to functions within plot.Spatial. When set to TRUE, par(“usr”) will be overwritten with c(xlim, ylim), which defaults to the bounding box of the spatial object. This is only needed in the particular context of graphic output to a specified device with given width and height, to be matched to the spatial object, when using par(“xaxs”) and par(“yaxs”) in addition to par(mar=c(0,0,0,0)).

Warning

this class is not useful in itself, but all spatial classes in this package derive from it

Examples

o <- new("Spatial")
proj4string(o) <- CRS("+init=epsg:27700")
if (!is.null(comment(slot(o, "proj4string")))) {
  cat(strsplit(wkt(o), "\n")[[1]], sep="\n")
  cat(strsplit(wkt(slot(o, "proj4string")), "\n")[[1]], sep="\n")
}
#> PROJCRS["OSGB36 / British National Grid",
#>     BASEGEOGCRS["OSGB36",
#>         DATUM["Ordnance Survey of Great Britain 1936",
#>             ELLIPSOID["Airy 1830",6377563.396,299.3249646,
#>                 LENGTHUNIT["metre",1]]],
#>         PRIMEM["Greenwich",0,
#>             ANGLEUNIT["degree",0.0174532925199433]],
#>         ID["EPSG",4277]],
#>     CONVERSION["British National Grid",
#>         METHOD["Transverse Mercator",
#>             ID["EPSG",9807]],
#>         PARAMETER["Latitude of natural origin",49,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8801]],
#>         PARAMETER["Longitude of natural origin",-2,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8802]],
#>         PARAMETER["Scale factor at natural origin",0.9996012717,
#>             SCALEUNIT["unity",1],
#>             ID["EPSG",8805]],
#>         PARAMETER["False easting",400000,
#>             LENGTHUNIT["metre",1],
#>             ID["EPSG",8806]],
#>         PARAMETER["False northing",-100000,
#>             LENGTHUNIT["metre",1],
#>             ID["EPSG",8807]],
#>         ID["EPSG",19916]],
#>     CS[Cartesian,2],
#>         AXIS["(E)",east,
#>             ORDER[1],
#>             LENGTHUNIT["metre",1,
#>                 ID["EPSG",9001]]],
#>         AXIS["(N)",north,
#>             ORDER[2],
#>             LENGTHUNIT["metre",1,
#>                 ID["EPSG",9001]]],
#>     USAGE[
#>         SCOPE["unknown"],
#>         AREA["United Kingdom (UK) - offshore to boundary of UKCS within 49°45'N to 61°N and 9°W to 2°E; onshore Great Britain (England, Wales and Scotland). Isle of Man onshore."],
#>         BBOX[49.75,-9,61.01,2.01]]]
#> PROJCRS["OSGB36 / British National Grid",
#>     BASEGEOGCRS["OSGB36",
#>         DATUM["Ordnance Survey of Great Britain 1936",
#>             ELLIPSOID["Airy 1830",6377563.396,299.3249646,
#>                 LENGTHUNIT["metre",1]]],
#>         PRIMEM["Greenwich",0,
#>             ANGLEUNIT["degree",0.0174532925199433]],
#>         ID["EPSG",4277]],
#>     CONVERSION["British National Grid",
#>         METHOD["Transverse Mercator",
#>             ID["EPSG",9807]],
#>         PARAMETER["Latitude of natural origin",49,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8801]],
#>         PARAMETER["Longitude of natural origin",-2,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8802]],
#>         PARAMETER["Scale factor at natural origin",0.9996012717,
#>             SCALEUNIT["unity",1],
#>             ID["EPSG",8805]],
#>         PARAMETER["False easting",400000,
#>             LENGTHUNIT["metre",1],
#>             ID["EPSG",8806]],
#>         PARAMETER["False northing",-100000,
#>             LENGTHUNIT["metre",1],
#>             ID["EPSG",8807]],
#>         ID["EPSG",19916]],
#>     CS[Cartesian,2],
#>         AXIS["(E)",east,
#>             ORDER[1],
#>             LENGTHUNIT["metre",1,
#>                 ID["EPSG",9001]]],
#>         AXIS["(N)",north,
#>             ORDER[2],
#>             LENGTHUNIT["metre",1,
#>                 ID["EPSG",9001]]],
#>     USAGE[
#>         SCOPE["unknown"],
#>         AREA["United Kingdom (UK) - offshore to boundary of UKCS within 49°45'N to 61°N and 9°W to 2°E; onshore Great Britain (England, Wales and Scotland). Isle of Man onshore."],
#>         BBOX[49.75,-9,61.01,2.01]]]