[R-sig-Geo] Counting points in cells and ploting only cells containing points
MIGUEL GOMEZ DE ANTONIO
mg@ @end|ng |rom ccee@ucm@e@
Wed Nov 22 12:40:18 CET 2023
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]]
More information about the R-sig-Geo
mailing list