Manuel, library(raster) # Assuming you have matrix of points (or SpatialPoints*) pt <- (cbind(runif(100), runif(100)) -0.5) * 500 spt <- SpatialPoints(pt) # and a RasterLayer r <- raster()
# you can do e <- polygonFromExtent(r) o <- overlay(e, spt) o <- which(!is.na(o)) pts <- pt[o,] # show that it worked plot(pt) r[] = 1 plot(r, add=TRUE, legend=FALSE) points(pt, col='blue') points(pts, col='red', pch=20) Robert On Thu, Nov 4, 2010 at 5:43 AM, Manuel Spínola <mspinol...@gmail.com> wrote: > Dear list members, > > How can eliminate or dismiss points that do not "touch" my raster file? > This mean those points that are outside of the raster area. > When I have my plot of the rester and I draw the points: > > points (villages) > > some of them are outside of the raster not because an error but just > because the point file is bigger in extent than the raster. > > 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 > mspin...@una.ac.cr > mspinol...@gmail.com > 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 > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo