

You can see that, for example, when you cast a multipoint consisting of five pairs of coordinates into a point. On the other hand, some of the transformations are splitting the single element input object into a multi-element object. Several of the transformations are not possible, for example, you cannot convert a single point into a multilinestring or a polygon (so the cells in the table are NA). Table 5.1 shows possible geometry type transformations on simple feature objects.Įach input simple feature object with only one element (first column) is transformed directly into another geometry type. One important difference is the conversion between multi-types to non-multi-types.Īs a result of this process, multi-objects are split into many non-multi-objects. Geometry casting of simple features geometry column ( sfc) and simple features objects works the same as for single geometries in most of the cases. However, only the first element of the old object would remain in the second group of cases.
#Define raster buffers how to
Importantly it shows how to ‘polygonize’ rasters and ‘rasterize’ vector datasets, making the two data models more interchangeable.įor single simple feature geometries ( sfg), st_cast also provides geometry casting from non-multi-types to multi-types (e.g., POINT to MULTIPOINT) and from multi-types to non-multi-types. It shows how raster values can be ‘masked’ and ‘extracted’ by vector geometries. The final Section 5.4 connects vector and raster objects. These operations are especially useful if one would like to align raster datasets from diverse sources.Īligned raster objects share a one-to-one correspondence between pixels, allowing them to be processed using map algebra operations, described in Section 4.3.2. It teaches how to change the resolution (also called raster aggregation and disaggregation), the extent and the origin of a raster. This involves changing the size and number of the underlying pixels, and assigning them new values. Section 5.3 covers geometric transformations on raster objects. Type transformations (from a polygon to a line, for example) are demonstrated in Section 5.2.7.

This includes clipping and geometry unions, covered in Sections 5.2.5 and 5.2.6, respectively. This includes simplification (of lines and polygons), the creation of buffers and centroids, and shifting/scaling/rotating single geometries using ‘affine transformations’ (Sections 5.2.1 to 5.2.4).īinary transformations modify one geometry based on the shape of another. Unary operations work on a single geometry in isolation. Section 5.2 covers transforming vector geometries with ‘unary’ and ‘binary’ operations. The previous three chapters have demonstrated how geographic datasets are structured in R (Chapter 2) and how to manipulate them based on their non-geographic attributes (Chapter 3) and spatial properties (Chapter 4).Īfter reading it - and attempting the exercises at the end - you should understand and have control over the geometry column in sf objects and the geographic location of pixels represented in rasters.

