Dear community, I want to plot only the cells of a grid that contains points.
I have a set of points (of class SpatialPointsDataFrame) and a grid (of class SpatialPolygonDataFrame). I am interested in ploting the set of cells of the grid that contains points: 1. Count how many points fall in each cell of the grid. 2. Plot only the cells that contains points. I tried: library(sf) Points.sf=st_as_sf(points) Grid.sf=st_as_sf(grid) A=intersects(grid.sf, points.sf) apply(A,1,any) There I get the cells that contains points but: 1. How can I count how many points fall in each cell 2. How could I plot the set of cells that contains points? Thank you very much for your help, Miguel Gómez de Antonio Profesor Titular de Universidad Dpto. Economía Aplicada, Pública y Política Universidad Complutense de Madrid [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo