R: Tiles (subsets or clips) a spatial object to regular blocks
tile
R Documentation
Tiles (subsets or clips) a spatial object to regular blocks
Description
Tiles objects of class "Spatial*" or "RasterLayer*" into regular blocks.
Usage
## S4 method for signature 'SpatialPointsDataFrame'
tile(x, y, block.x, ...)
## S4 method for signature 'SpatialPixelsDataFrame'
tile(x, y, block.x, ...)
## S4 method for signature 'SpatialPolygonsDataFrame'
tile(x, y, block.x, tmp.file = TRUE,
program, show.output.on.console = FALSE, ...)
## S4 method for signature 'SpatialLinesDataFrame'
tile(x, y, block.x, tmp.file = TRUE,
program, show.output.on.console = FALSE, ...)
## S4 method for signature 'RasterLayer'
tile(x, y, block.x, tmp.file = TRUE,
program, show.output.on.console = FALSE, ...)
Arguments
x
object of class "Spatial*""RasterLayer"
y
list of "SpatialPolygons"; if missing will be derived based on block.x
block.x
numeric; size of block in meters or corresponding mapping units
tmp.file
logical; specifies whether to generate a temporary file
program
character; location of the auxiliary program in the system
show.output.on.console
logical; specifies whether to print the progress of a function
...
optional arguments that can be passed to the getSpatialTiles
Details
When working with objects of type "SpatialLinesDataFrame", "SpatialPolygonsDataFrame" and or "RasterLayer", the function looks for FWTools binary files ogr2ogr and warp. FWTools is a separate program and must be installed separately.
Value
Returns a list of objects of the same class as the input object.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(GSIF)
GSIF version 0.5-2 (2016-06-25)
URL: http://gsif.r-forge.r-project.org/
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GSIF/tile.Rd_%03d_medium.png", width=480, height=480)
> ### Name: tile
> ### Title: Tiles (subsets or clips) a spatial object to regular blocks
> ### Aliases: tile tile,SpatialPixelsDataFrame-method
> ### tile,SpatialPointsDataFrame-method tile,SpatialLinesDataFrame-method
> ### tile,SpatialPolygonsDataFrame-method tile,RasterLayer-method
> ### Keywords: methods
>
> ### ** Examples
>
> ## spatial pixels:
> library(sp)
> data(meuse.grid)
> gridded(meuse.grid) <- ~x+y
> tl <- getSpatialTiles(meuse.grid, block.x=1000)
Generating 20 tiles...
Returning a list of tiles for an object of class SpatialPixelsDataFrame with 0 percent overlap
> image(meuse.grid)
> lines(as(tl, "SpatialLines"))
> ## all at once:
> pix.lst <- tile(meuse.grid, block.x=1000)
Generating 20 tiles...
Returning a list of tiles for an object of class SpatialPixelsDataFrame with 0 percent overlap
Subseting object of class "SpatialPixelsDataFrame"...
> ## Not run:
> ##D ## lines:
> ##D library(plotKML)
> ##D data(eberg_contours)
> ##D line.lst <- tile(eberg_contours, block.x=5000)
> ##D spplot(line.lst[[1]][2])
> ##D ## polygons:
> ##D data(eberg_zones)
> ##D ## this one requires ogr2ogr function:
> ##D pol.lst <- tile(eberg_zones, block.x=5000)
> ##D spplot(pol.lst[[1]][1])
> ##D ## raster files via rgdal:
> ##D library(rgdal)
> ##D fn = system.file("pictures/SP27GTIF.TIF",
> ##D package = "rgdal")
> ##D obj <- GDALinfo(fn)
> ##D ras.lst <- getSpatialTiles(obj, block.x=1000)
> ##D offset <- c(ras.lst$offset.y[1], ras.lst$offset.x[1])
> ##D region.dim <- c(ras.lst$region.dim.y[1],
> ##D ras.lst$region.dim.x[1])
> ##D ## read the first tile:
> ##D SP27GTIF_T1 <- readGDAL(fn, offset=offset,
> ##D region.dim=region.dim)
> ##D str(SP27GTIF_T1)
> ## End(Not run)
>
>
>
>
>
> dev.off()
null device
1
>