![]() Terra package has its own class for vector data, called SpatVector. You can make it a RasterBrick using raster::brick(): IA_cdl_stack is of class RasterStack, and it has two layers of variables: CDL for 20. To create a RasterStack and RasterBrick, let’s load the CDL data for IA in 2016 and stack it with the 2015 data. Often times, processing a multi-layer object has computational advantages over processing multiple single-layer one by one 72. You can stack multiple raster layers of the same spatial resolution and extent to create a RasterStack using raster::stack() or RasterBrick using raster::brick(). A RasterLayer consists of only one layer, meaning that only a single variable is associated with the cells (here it is land use category code in integer). The class of the downloaded data is RasterLayer, which is a raster data class defined by the raster package. class : RasterLayerĭimensions : 11671, 17795, 207685445 (nrow, ncol, ncell)Įxtent : -52095, 481755, 1938165, 2288295 (xmin, xmax, ymin, ymax)Ĭrs : +proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defsĮvaluating the imported raster object provides you with information about the raster data, such as dimensions (number of cells, number of columns, number of cells), spatial resolution (30 meter by 30 meter for this raster data), extent, CRS and the minimum and maximum values recorded in this raster layer. We will use the CDL data for Iowa in 2015. Let’s start with taking a look at raster data. It also allows you to apply dplyr verbs for data wrangling.Ĥ.1.1 raster package: RasterLayer, RasterStack, and RasterBrick It provides a data model that makes working with raster data with temporal dimensions easier. ![]() ![]() This is because other useful packages for us economists were written to work with the raster object classes and have still not been adapted to support terra object classes at the moment.įinally, you might benefit from learning the stars package for raster data operations (covered in Chapter 7), particularly if you often work with raster data with the temporal dimension (e.g., PRISM, Daymet). Those who are interested in a fuller treatment of the raster or terra package are referred to Spatial Data Science with R and “terra” or Chapters 3, 4, and 5 of Geocomputation with R, respectively.Įven though the terra package is a replacement of the raster package and it has been out on CRAN for more than several years, we still learn the raster object classes defined by the raster package and how to switch between the raster and terra object classes. For example, we do not cover raster arithmetic, focal operations, or aggregation. Therefore, we will introduce only the essential knowledge of raster data operation required to effectively implement the task of extracting values, which will be covered extensively in Chapter 5. Key differences will be discussed and will become clear later.įor economists, raster data extraction for vector data will be by far the most common use case of raster data and also the most time-consuming part of the whole raster data handling experience. The raster and terra packages share the same function name for many of the raster operations. terra is written in C++ and thus is faster than the raster package in many raster data operations. The terra package has been under active development to replace the raster package (see the most up-to-date version of the package here). However, we are in the period of transitioning from the raster package to the terra package. The raster package has been the most popular and commonly used package for raster data handling. In this chapter, we will learn how to use the raster and terra package to handle raster data.
0 Comments
Leave a Reply. |