Paulo, If the polygon does not cover half the edge-pixel, it is ignored. That should probably change so that all cells that are touched are included.
To be safe you could use a slightly larger extent, as in: e <- intersectExtent(x, extent(y)) + 2 * xres(x) crop(x, e) Robert On Fri, Oct 15, 2010 at 8:50 AM, Paulo Brando <[email protected]> wrote: > Dear All, > > I have been using the crop function in the raster package, but haven't > figured out yet how this function deals with pixels that falls on the edge > of a polygon. > > Thanks, > > Paulo > > On Thu, Oct 14, 2010 at 12:42 PM, Manuel Spínola <[email protected]> > wrote: >> >> Thank you very much Robert. >> That's works perfect. >> >> Manuel >> >> On 14/10/2010 10:21 a.m., Robert J. Hijmans wrote: >> > Manuel, >> > >> > if "costarica" is a SpatialPolygons* object, you can do: >> > >> > r<- raster("bio1_23.bil") >> > cr<- crop(r, costarica) >> > >> > Robert >> > >> > On Thu, Oct 14, 2010 at 8:16 AM, Manuel Spínola<[email protected]> >> > wrote: >> >> Dear list members, >> >> >> >> I download bioclim data in a raster format (estension: .bil) and I >> >> would >> >> like to clip the variables to a ploygon stored as a shapefile (Costa >> >> Rica outline). >> >> How can I do that? >> >> >> >> I read the raster file like this: >> >> >> >> x<- readGDAL("bio1_23.bil") >> >> >> >> Thank you very much in advance. >> >> Best, >> >> >> >> Manuel >> >> >> >> >> >> -- >> >> *Manuel Spínola, Ph.D.* >> >> Instituto Internacional en Conservación y Manejo de Vida Silvestre >> >> Universidad Nacional >> >> Apartado 1350-3000 >> >> Heredia >> >> COSTA RICA >> >> [email protected] >> >> [email protected] >> >> Teléfono: (506) 2277-3598 >> >> Fax: (506) 2237-7036 >> >> Personal website: Lobito de río >> >> <https://sites.google.com/site/lobitoderio/> >> >> Institutional website: ICOMVIS<http://www.icomvis.una.ac.cr/> >> >> >> >> [[alternative HTML version deleted]] >> >> >> >> >> >> _______________________________________________ >> >> R-sig-Geo mailing list >> >> [email protected] >> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> >> >> >> >> >> >> -- >> *Manuel Spínola, Ph.D.* >> Instituto Internacional en Conservación y Manejo de Vida Silvestre >> Universidad Nacional >> Apartado 1350-3000 >> Heredia >> COSTA RICA >> [email protected] >> [email protected] >> Teléfono: (506) 2277-3598 >> Fax: (506) 2237-7036 >> Personal website: Lobito de río >> <https://sites.google.com/site/lobitoderio/> >> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/> >> >> [[alternative HTML version deleted]] >> >> >> _______________________________________________ >> R-sig-Geo mailing list >> [email protected] >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> > > _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
