EVOLUTION-MANAGER
Edit File: erase.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Erase parts of a SpatialPolygons* or SpatialLines* object....</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for erase {raster}"><tr><td>erase {raster}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Erase parts of a SpatialPolygons* or SpatialLines* object. The inverse of this can be done with <code><a href="intersect.html">intersect</a></code> </h2> <h3>Description</h3> <p>Erase parts of a SpatialPolygons* or SpatialLines* object with a SpatialPolygons* object </p> <h3>Usage</h3> <pre> ## S4 method for signature 'SpatialPolygons,SpatialPolygons' erase(x, y, ...) ## S4 method for signature 'SpatialLines,SpatialPolygons' erase(x, y, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>SpatialPolygons or SpatialLines object</p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>SpatialPolygons object</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments (none)</p> </td></tr> </table> <h3>Value</h3> <p>Spatial* </p> <h3>Author(s)</h3> <p>Robert J. Hijmans</p> <h3>See Also</h3> <p>The equivalent for raster data is <code><a href="mask.html">mask</a></code></p> <h3>Examples</h3> <pre> if (require(rgdal) & require(rgeos)) { # erase parts of polygons with other polygons p <- shapefile(system.file("external/lux.shp", package="raster")) b <- as(extent(6, 6.4, 49.75, 50), 'SpatialPolygons') crs(b) <- crs(p) e <- erase(p, b) plot(e) # erase parts of lines with polygons r <- raster(extent(p) +c(-.1,.1,-.1,.1), crs=crs(p)) start <- xyFromCell(r, cellFromCol(r, 1)) end <- xyFromCell(r, cellFromCol(r, ncol(r))) lines <- do.call(spLines, lapply(1:10, function(i)rbind(start[i,], end[i,]))) crs(lines) <- crs(p) e2 <- erase(lines, p) plot(p) lines(lines, col='blue', lwd=4, lty=3) lines(e2, col='red', lwd=2) } </pre> <hr /><div style="text-align: center;">[Package <em>raster</em> version 3.3-13 <a href="00Index.html">Index</a>]</div> </body></html>