Rebecca Wooldridge [bs13rw]
2016-Mar-16 22:09 UTC
[R] R count.points thinks projections are different
I am currently working with telemetry data for some cats: x<-read.csv("CCATS.csv") obs2<-x[c("ID", "X", "Y")] dat_df <- obs2 %>% dplyr::select(ID) %>% as.data.frame() p4s <- "+proj=utm +zone=16 +ellps=clrk66 +datum=NAD27 +units=m +no_defs" p4s_crs <- CRS(p4s) xy <- obs2 %>% dplyr::select(X, Y) %>% as.matrix() xy_sp <- SpatialPointsDataFrame(xy, data = dat_df, proj4string=p4s_crs) I also have some raster maps of the study area:> summary(habitat)Object of class SpatialPixelsDataFrame Coordinates: min max x 328048.6 360028.8 y 1841819.0 1874744.0 Is projected: TRUE proj4string : [+proj=utm +zone=16 +ellps=clrk66 +datum=NAD27 +units=m +no_defs +nadgrids=@conus, at alaska, at ntv2_0.gsb, at ntv1_can.dat] Number of points: 13024 Grid attributes: cellcentre.offset cellsize cells.dim s1 328139.5 181.7057 176 s2 1842041.5 444.9324 74 Data attributes: elevation ecosystem slope aspect Min. : 1.000 Min. : 1.00 Min. :0.00000 Min. : 0.0 1st Qu.: 1.000 1st Qu.:15.00 1st Qu.:0.00000 1st Qu.: 90.0 Median : 2.000 Median :15.00 Median :0.04134 Median : 90.0 Mean : 2.263 Mean :12.85 Mean :0.05194 Mean :132.5 3rd Qu.: 3.000 3rd Qu.:15.00 3rd Qu.:0.08523 3rd Qu.:180.0 Max. :11.000 Max. :18.00 Max. :0.35079 Max. :360.0 NA's :18 NA's :84 NA's :84 when i try to use the count.points function i get the following message: Error in count.points(SpatialPoints(x), w) : different proj4string in w and xy but> identical(proj4string(habitat), proj4string(xy_sp))[1] TRUE and i have also tried proj4string(xy_sp) <- proj4string(habitat) and then running again but i still get the same error message. Any help would be greatly appreciated. Becky [[alternative HTML version deleted]]