## ---- echo=FALSE, include=FALSE----------------------------------------------- library(knitr) opts_chunk$set(fig.width = 5, fig.height = 5, fig.cap='', collapse = TRUE) library(raster) library(rgdal) ## ---- shp1-------------------------------------------------------------------- library(raster) filename <- system.file("external/lux.shp", package="raster") filename ## ---- shp2-------------------------------------------------------------------- s <- shapefile(filename) s ## ---- shp3-------------------------------------------------------------------- outfile <- 'test.shp' shapefile(s, outfile, overwrite=TRUE) ## ---- echo=FALSE, include=FALSE----------------------------------------------- ff <- list.files(patt="^test") file.remove(ff) ## ---- ras0-------------------------------------------------------------------- f <- system.file("external/rlogo.grd", package="raster") f ## ---- ras1-------------------------------------------------------------------- r1 <- raster(f) r1 ## ---- ras2-------------------------------------------------------------------- r2 <- raster(f, band=2) r2 ## ---- ras3-------------------------------------------------------------------- b <- brick(f) b ## ---- ras4-------------------------------------------------------------------- s <- stack(f) s ## ---- ras5-------------------------------------------------------------------- x <- writeRaster(s, 'output.tif', overwrite=TRUE) x ## ---- echo=FALSE, include=FALSE----------------------------------------------- file.remove('output.tif')