Sf provides the same functionality (and more) previously provided in three packages - sp for data classes ( Pebesma and Bivand 2018), rgdal for data read/write via an interface to GDAL and PROJ ( Bivand, Keitt, and Rowlingson 2018) and rgeos for spatial operations via an interface to GEOS ( Bivand and Rundel 2018). Sf also supports geometry collections, which can contain multiple geometry types in a single object. Sf can represent all common vector geometry types (raster data classes are not supported by sf): points, lines, polygons and their respective ‘multi’ versions (which group together features of the same type into a single feature). There is more to CRSs, as described in Sections 2.4 and 7 but, for the purposes of this section, it is sufficient to know that coordinates consist of two numbers representing distance from an origin, usually in \(x\) then \(y\) dimensions.įIGURE 2.2: Simple feature types fully supported by sf. The location of National Grid’s origin, in the sea beyond South West Peninsular, ensures that most locations in the UK have positive Easting and Northing values. This can be verified visually: slightly more than 5 ‘boxes’ - square areas bounded by the gray grid lines 100 km in width - separate the point representing London from the origin (Figure 2.1, right panel). The same point could also be approximated in a projected CRS with ‘Easting/Northing’ values of c(530000, 180000) in the British National Grid, meaning that London is located 530 km East and 180 km North of the \(origin\) of the CRS. The origin in this case is at 0 degrees longitude (the Prime Meridian) and 0 degree latitude (the Equator) in a geographic (‘lon/lat’) CRS (Figure 2.1, left panel). This means that its location is -0.1 degrees east and 51.5 degrees north of the origin. In this system London, for example, can be represented by the coordinates c(-0.1, 51.5). Most point geometries contain only two dimensions (3-dimensional CRSs contain an additional \(z\) value, typically representing height above sea level). Points can represent self-standing features (e.g., the location of a bus stop) or they can be linked together to form more complex geometries such as lines and polygons. The geographic vector data model is based on points located within a coordinate reference system (CRS). Still, there is a link between the two: the spatial coordinates which are at the heart of the geographic vector data model can be represented in R using vector objects. The former is a data model, the latter is an R class just like ame and matrix. Geographic vector data and the vector class (note the monospace font) in R. Take care when using the word ‘vector’ as it can have two meanings in this book: This book uses sf and terra packages to work with vector data and raster datasets, respectively. Whether your work involves more use of vector or raster datasets, it is worth understanding the underlying data model before using them, as discussed in subsequent chapters. There is much overlap in some fields and raster and vector datasets can be used together:Įcologists and demographers, for example, commonly use both vector and raster data.įurthermore, it is possible to convert between the two forms (see Section 6).