Learn R Programming

ipdw (version 0.2-2)

costrasterGen: Generate a cost Raster

Description

Generate a cost raster from an object of class SpatialPolygons, matrix, or SpatialPointsDataFrame

Usage

costrasterGen(xymat, pols, extent = "polys", projstr)

Arguments

xymat
Matrix of coordinates or a SpatialPointsDataFrame object
pols
SpatialPolygons object
extent
Define extent based on extent of xymat/xyspdf (points) or pols (polys). Default is polys.
projstr
proj4 string defining the inherent projection

Value

  • RasterLayer

Details

Ensure that the projection of the xymat coordinates and pols match. This can be accomplished by running the projection command on both inputs. If they do not match use the spTransform command.

See Also

spTransform-methods, rasterize

Examples

Run this code
Sr1<-Polygon(cbind(c(0,0,2,2,0),c(0,4,4,0,0)))
Sr2<-Polygon(cbind(c(2,2,4,4,2),c(0,2,2,0,0)))
Srs1<-Polygons(list(Sr1), "s1")
Srs2<-Polygons(list(Sr2), "s2")
pols<-SpatialPolygons(list(Srs1,Srs2), 1:2)

#using a matrix object
xymat<-matrix(3,3,nrow=1,ncol=2)
costras<-costrasterGen(xymat,pols,projstr=NULL)


#plotting
plot(costras)
points(xymat)

Run the code above in your browser using DataLab