Learn R Programming

geostatsp (version 1.2.1)

squareRaster: Create a raster with square cells

Description

Given a raster object, an extent, or a bounding box, a raster of with square cells and having the extent and number of cells specified is returned.

Usage

squareRaster(x,  cells=NULL)
	## S3 method for class 'RasterLayer':
squareRaster(x,cells=NULL)
	## S3 method for class 'BasicRaster':
squareRaster(x,cells=NULL)
	## S3 method for class 'matrix':
squareRaster(x,cells=NULL)
	## S3 method for class 'Extent':
squareRaster(x,cells=NULL)
	## S3 method for class 'SpatialPoints':
squareRaster(x,cells=NULL)
	## S3 method for class 'SpatialPointsDataFrame':
squareRaster(x,cells=NULL)
	## S3 method for class 'SpatialPolygons':
squareRaster(x,cells=NULL)
	## S3 method for class 'SpatialPolygonsDataFrame':
squareRaster(x,cells=NULL)

Arguments

x
A bounding box from a SpatialPoints or SpatialPolygons object or an Extent from a Raster.
cells
The number of cells in the x direction. If NULL the number of columns of x is used.

Value

  • A raster.

Examples

Run this code
myraster = raster(matrix(0,10,10),xmn=0,xmx=10,ymn=0,ymx=12.3)

squareRaster(myraster)

squareRaster(extent(myraster), cells=10)

squareRaster(bbox(myraster), cells=10)

Run the code above in your browser using DataLab