To subsample a raster in R, we can use the raster
package. The raster
package is widely used for working with raster data because of its efficient and fast processing.
First, install and load the raster
package:
45 chars3 lines
Next, we can load the raster file:
35 chars2 lines
To subsample the raster, we can use the resample()
function. For example, if we want to reduce the resolution of the raster to half, we can use the following code:
40 chars2 lines
The res
argument specifies the desired resolution of the output raster. In this case, we multiply the original resolution by 2 to reduce it to half.
We can then save the subsampled raster as follows:
54 chars2 lines
This will save the subsampled raster to the specified file location.
gistlibby LogSnag