# NOT RUN {
# Create a RasterLayer object from a file
# N.B.: For your own files, omit the 'system.file' and 'package="raster"' bits
# these are just to get the path to files installed with the package
f <- system.file("external/test.grd", package="raster")
f
r <- raster(f)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
#from scratch
r1 <- raster(nrows=108, ncols=21, xmn=0, xmx=10)
#from an Extent object
e <- extent(r)
r2 <- raster(e)
#from another Raster* object
r3 <- raster(r)
s <- stack(r, r, r)
r4 <- raster(s)
r5 <- raster(s, 3)
# }
# NOT RUN {
# from NSIDC sea ice concentration file
baseurl <- "ftp://sidads.colorado.edu/pub/DATASETS/"
# southern hemisphere
f1 <- paste(baseurl,
"nsidc0051_gsfc_nasateam_seaice/final-gsfc/south/daily/2013/nt_20130114_f17_v01_s.bin",
sep='')
# or northern hemisphere
f2 <- paste(baseurl,
"nsidc0051_gsfc_nasateam_seaice/final-gsfc/north/daily/2013/nt_20130105_f17_v01_n.bin",
sep='')
if (!file.exists(basename(f1))) download.file(f1, basename(f1), mode = "wb")
ice1 <- raster(basename(f1))
if (!file.exists(basename(f2))) download.file(f2, basename(f2), mode = "wb")
ice2 <- raster(basename(f2))
# }
Run the code above in your browser using DataLab