Because these graphics are not based on pixels, they are known as resolution independent, which makes them infinitely scalable. These graphics consist of anchored dots and are connected by lines and curves, similar to the connect-the-dot activities you may have done as a kid. # create three identical RasterLayer objects r1 <- r2 <- r3 <- raster ( nrow = 10, ncol = 10 ) # Assign random cell values values ( r1 ) <- runif ( ncell ( r1 )) values ( r2 ) <- runif ( ncell ( r2 )) values ( r3 ) <- runif ( ncell ( r3 )) # combine three RasterLayer objects into a RasterStack s <- stack ( r1, r2, r3 ) s # class : RasterStack # dimensions : 10, 10, 100, 3 (nrow, ncol, ncell, nlayers) # resolution : 36, 18 (x, y) # extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) # crs : +proj=longlat +datum=WGS84 +no_defs # names : layer.1, layer.2, layer.3 # min values : 0.01307758, 0.02778712, 0.06380247 # max values : 0.9926841, 0.9815635, 0.9960774 nlayers ( s ) # 3 # combine three RasterLayer objects into a RasterBrick b1 <- brick ( r1, r2, r3 ) # equivalent to: b2 <- brick ( s ) # create a RasterBrick from file filename <- system.file ( "external/d", package = "raster" ) filename # "C:/soft/R/R-devel/library/raster/external/d" b <- brick ( filename ) b # class : RasterBrick # dimensions : 77, 101, 7777, 3 (nrow, ncol, ncell, nlayers) # resolution : 1, 1 (x, y) # extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax) # crs : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs # source : rlogo.Vector graphics are also known as scalable vector graphics (SVG). Package), using a file in the native ‘raster-file’ format: Here is an example using the ‘Meuse’ dataset (taken from the sp Most formats supported for reading can also be written Supported formats for reading include GeoTIFF, ESRI,ĮNVI, and ERDAS. Including some ‘natively’ supported formats and other formats via the The raster package can use raster files in several formats, It is more common, however, to create a RasterLayer object from aįile. Object, a matrix, an ‘im’ object (SpatStat), and ‘asc’ and ‘kasc’ SpatialGrid* object (defined in the sp package), an Extent RasterBrick, as well as from a SpatialPixels* and The function raster also allows you to create a RasterLayer fromĪnother object, including another RasterLayer, RasterStack and HasValues ( r ) # TRUE res ( r ) # 36 18 dim ( r ) # 10 10 1 xmax ( r ) # 180 # change the maximum x coordinate of the extent (bounding box) of the RasterLayer xmax ( r ) <- 0 hasValues ( r ) # TRUE res ( r ) # 18 18 dim ( r ) # 10 10 1 ncol ( r ) <- 6 hasValues ( r ) # FALSE res ( r ) # 30 18 dim ( r ) # 10 6 1 xmax ( r ) # 0 Where the raster is located in geographic space, but there are noĬell-values associated with it. “skeleton”, that is, we have defined the number of rows and columns, and The object x created in the example above only consist of a Library ( raster ) # RasterLayer with the default parameters x <- raster () x # class : RasterLayer # dimensions : 180, 360, 64800 (nrow, ncol, ncell) # resolution : 1, 1 (x, y) # extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) # crs : +proj=longlat +datum=WGS84 +no_defs # With other parameters x <- raster ( ncol = 36, nrow = 18, xmn = -1000, xmx = 1000, ymn = -100, ymx = 900 ) # that can be changed res ( x ) # 55.55556 55.55556 # change resolution res ( x ) <- 100 res ( x ) # 100 100 ncol ( x ) # 20 # change the numer of columns (affects resolution) ncol ( x ) <- 18 ncol ( x ) # 18 res ( x ) # 111.1111 100.0000 # set the coordinate reference system (CRS) (define the projection) projection ( x ) <- "+proj=utm +zone=48 +datum=WGS84" x # class : RasterLayer # dimensions : 10, 18, 180 (nrow, ncol, ncell) # resolution : 111.1111, 100 (x, y) # extent : -1000, 1000, -100, 900 (xmin, xmax, ymin, ymax) # crs : +proj=utm +zone=48 +datum=WGS84 +units=m +no_defs
0 Comments
Leave a Reply. |