R: Wie kann ich zählen, wie viele Punkte sich in jeder Zelle meines Gitters befinden?

Ich habe ein Referenzgitter mit einer Größe von 50 x 50 m erstellt, das auf den GPS-Positionen eines Tieres mit Halsband basiert. Ich möchte das Äquivalent zu einer räumlichen Verknüpfung in ArcGIS ausführen und die Anzahl der Punkte in jeder Zelle zählen.

Ich habe ein Referenzgitter mit einem SpatialPointsDataFrame-Objekt erstellt (der Datenrahmen wird bereits mit dem UTM-Koordinatensystem projiziert).

RESO <- 50 # grid resolution (m)
BUFF <- 500 # grid extent (m) (buffer around location extremes) 
XMIN <- RESO*(round(((min(dat.spdf$Longitude)-BUFF)/RESO),0))
YMIN <- RESO*(round(((min(dat.spdf$Latitude)-BUFF)/RESO),0))
XMAX <- XMIN+RESO*(round(((max(dat.spdf$Longitude)+BUFF-XMIN)/RESO),0))
YMAX <- YMIN+RESO*(round(((max(dat.spdf$Latitude)+BUFF-YMIN)/RESO),0))
NRW <- ((YMAX-YMIN)/RESO)
NCL <- ((XMAX-XMIN)/RESO)
refgrid<-raster(nrows=NRW, ncols=NCL, xmn=XMIN, xmx=XMAX, ymn=YMIN, ymx=YMAX) 
refgrid<-as(refgrid,"SpatialPixels")

Um sicherzustellen, dass sich mein Raster in derselben Projektion wie die SpatialPoints befand:

proj4string(refgrid)=proj4string(dat.sp.utm) #makes the grid the same CRS as point

count.point Funktion in adehabitatMA scheint wie die Funktion, die den Trick machen wird

cp<- count.points(dat.spdf, refgrid)

Aber ich bekomme diesen Fehler:

Error in w[[1]] : no [[ method for object without attributes

Ist dies nicht der richtige Weg, um mein Ziel zu erreichen? Oder wie kann ich diesen Fehler beheben? Oder würde dasover Funktion (SP-Paket) besser geeignet sein?

output from SpatialPointsDataFrame (dat.spdf)

dput(head(dat.spdf, 20))
structure(list(Latitude = c(5.4118432, 5.4118815, 5.4115713, 
5.4111541, 5.4087853, 5.4083702, 5.4082527, 5.4078161, 5.4075528, 
5.407321, 5.4070598, 5.4064237, 5.4070621, 5.4070555, 5.4065127, 
5.4065134, 5.4064872, 5.4056724, 5.4038751, 5.4024223), Longitude = c(118.0225467, 
118.0222841, 118.0211875, 118.0208637, 118.0205413, 118.0206064, 
118.0204101, 118.0209272, 118.0213827, 118.0214189, 118.0217748, 
118.0223343, 118.0227079, 118.0226916, 118.0220733, 118.02218, 
118.0221843, 118.0223316, 118.0198153, 118.0196021), DayNo = c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L)), .Names = c("Latitude", "Longitude", "DayNo"), row.names = c(1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 15L, 16L, 
17L, 18L, 19L, 20L, 21L), class = "data.frame",)

Und Zusammenfassung:

summary(dat.spdf)
Object of class SpatialPointsDataFrame
Coordinates:
           min      max
Longitude 610361.0 613575.5
Latitude  596583.5 599385.2
Is projected: TRUE 
proj4string : [+proj=utm +zone=50 +ellps=WGS84]
Number of points: 5078
Data attributes:
Latitude       Longitude       DayNo      
Min.   :5.396   Min.   :118   Min.   :  1.0  
1st Qu.:5.404   1st Qu.:118   1st Qu.: 92.0  
Median :5.406   Median :118   Median :183.0  
Mean   :5.407   Mean   :118   Mean   :182.6  
3rd Qu.:5.408   3rd Qu.:118   3rd Qu.:273.0  
Max.   :5.422   Max.   :118   Max.   :364.0  

Antworten auf die Frage(4)

Ihre Antwort auf die Frage