<div dir="ltr"><div class="gmail_extra">Alexandre,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Atualizei seu CMR, adicionando as últimas linhas para realizar o recorte com um polígono irregular.</div><div class="gmail_extra">
<div class="gmail_extra"><br></div><div class="gmail_extra">### <code r<font face="courier new, monospace">></font></div><div class="gmail_extra"><font face="courier new, monospace">require(sp); require(rgdal); require(raster)</font></div>
<div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace">## Raster-----------------------------------------------------------</font></div><div class="gmail_extra">
<font face="courier new, monospace">set.seed(20131226)</font></div><div class="gmail_extra"><font face="courier new, monospace">r <- raster(nc=100, nr=100)</font></div><div class="gmail_extra"><font face="courier new, monospace">r <- setValues(r, round(runif(ncell(r))* 255))</font></div>
<div class="gmail_extra"><font face="courier new, monospace">image(r,col=gray(seq(0,1,0.025)))</font></div><div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace">## Borda -----------------------------------------------------------</font></div>
<div class="gmail_extra"><font face="courier new, monospace">x<-c(-125,-100,0,100,-125)</font></div><div class="gmail_extra"><font face="courier new, monospace">y<-c(-49,25,0,-50,-49)</font></div><div class="gmail_extra">
<font face="courier new, monospace">limite<-cbind(x,y)</font></div><div class="gmail_extra"><font face="courier new, monospace">lines(limite, col="yellow")</font></div><div class="gmail_extra"><font face="courier new, monospace">##</font></div>
<div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace">## Converte borda para SpatialPolygon</font></div><div class="gmail_extra"><font face="courier new, monospace">spt.borda <- SpatialPolygons(list(Polygons(list(Polygon(limite)), "1")))</font></div>
<div class="gmail_extra"><font face="courier new, monospace"><br></font></div><div class="gmail_extra"><font face="courier new, monospace">### Recorte do raster contido no interior da borda</font></div><div class="gmail_extra">
<font face="courier new, monospace">r.crop <- crop(r, spt.borda, snap='out')</font></div><div class="gmail_extra"><font face="courier new, monospace">image(r.crop, asp=1)</font></div><div class="gmail_extra"><font face="courier new, monospace"><br>
</font></div><div class="gmail_extra"><font face="courier new, monospace">### Recorte com polígono irregular! </font></div><div class="gmail_extra"><font face="courier new, monospace">r.masked <- mask(r.crop, spt.borda)</font></div>
<div class="gmail_extra"><font face="courier new, monospace">image(r.masked, asp=1)</font></div><div class="gmail_extra"><font face="courier new, monospace">### </code></font></div><div class="gmail_extra"><br></div>
<div class="gmail_extra"><br></div></div></div>