Description Usage Arguments Value Examples
This function rasterize a vector data by gdal binary utils. This is a wrap function of gdalUtils::gdal_rasterize.
1 | rasterize.gdal(obj, field, res = 10000, extent = NULL)
|
obj |
a Spatial*DataFrame objects. |
field |
character.The column name of the variable to be transferred |
res |
numeric.Resolution of the output raster |
extent |
extent object.Spatial extent of output raster.If missing, the extent of x will be used. |
RasterLayer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ###############################
# rasterize points
###############################
library(raster)
r <- raster(ncols=36, nrows=18)
n <- 1000
x <- runif(n) * 360 - 180
y <- runif(n) * 180 - 90
xy <- cbind(x, y)
# with a SpatialPointsDataFrame
vals <- 1:n
p <- data.frame(xy, name=vals)
coordinates(p) <- ~x+y
## If you are using windows,you must set local GDAL installation options before running function####'
install.gdal()
r2 <- rasterize.gdal(p, field = 'name', res =res(r)[1],extent=extent(r))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.