[R-sig-eco] adehabitatMA/adehabitatHS count.points / mimage(cp) Errors

R.J.Ward rjw53 at kent.ac.uk
Wed May 4 17:17:03 CEST 2016


Hi,

I have been working with the adehabitatMA, HS, HR and LT packages, and have become stuck due to an error whilst using the count.points and subsequent mimage() functions during analyses of habitat selection of 12 radiotracked snakes. I wasn't sure if this was more relevant to R-sig-geo or here so I hope this is a suitable place to post.

I would greatly appreciate any help as I've not managed to solve it despite checking forums, the vignette and other R Documentation. I have produced the errors below with some shortened code to show the process.
'Locs' contains our relocations for 12 snakes, and 'map' is a SpatialPixelsDataFrame consisting of stacked rasters of vegetation and other environmental variables such as slope and aspect.


>class(locs) # Check class
[1] "SpatialPointsDataFrame"
>class(map) # Check class
[1] "SpatialPixelsDataFrame"
attr(,"package")
[1] "sp"
>proj4string(locs)==proj4string(map) # Check projections match
[1] TRUE
>cp<-count.points(locs,map) # Count points
Error in count.points(SpatialPoints(x), w) :
different proj4string in w and xy
# I have seen in a forum <http://stackoverflow.com/questions/16519639/why-does-r-think-the-projection-data-are-different> that it may be worth trying it as a SpatialPoints format instead so I ran:
>locs_sp<-as(locs, "SpatialPoints")
> class(locs_sp)
[1] "SpatialPoints"
attr(,"package")
[1] "sp"
## This works, but when I run the following there is another error using mimage:
>cp.sp<-count.points(locs_sp, map)
>mimage(cp.sp)
Error in checkSlotAssignment(object, name, value) :
assignment of an object of class "numeric" is not valid for slot 'data' in an object of class "SpatialPixelsDataFrame"; is(value, "data.frame") is not TRUE
I am unable to proceed past this point and run the associated K-select analysis in section 5.1 of the vignette without solving this issue. I've noticed that in the example data (lynxjura) there is no associated projection, and am wondering if perhaps the projection is the cause of the issue?

If it is useful, below is the structure of my relocation data. I am assuming one key issue with converting it to SpatialPoints is that the unique ID codes for each animal are lost.

> str(locs)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
..@ data :'data.frame': 970 obs. of 1 variable:
.. ..$ Code: Factor w/ 12 levels "LMNN003X","LMNN005X",..: 1 1 1 1 1 1 1 1 1 1 ...
..@ coords.nrs : num(0)
..@ coords : num [1:970, 1:2] 33176 33175 33175 33175 33175 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "X" "Y"
..@ bbox : num [1:2, 1:2] 33081 69752 33617 70571
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "X" "Y"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..@ projargs: chr "+init=epsg:3109 +proj=tmerc +lat_0=49.225 +lon_0=-2.135 +k=0.9999999000000001 +x_0=40000 +y_0=70000 +ellps=GRS80 +towgs84=0,0,0"| __truncated__

Kind regards,

Rob


________________________________
Robert J. Ward |PhD Candidate - Biodiversity Management| DICE, University of Kent School of Anthropology and Conservation, Marlowe Building, University of Kent, Canterbury, CT2 7NR | Tel: +44(0)7747751180 / (0)1227824076 | E-mail: rjw53 at kent.ac.uk<https://owa.connect.kent.ac.uk/ecp/Customize/rjw53@kent.ac.uk> | Skype: rob.j.ward | [https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcThgccJHtviidhvODxhoa7UnIr6l25te5OLkN7ikQyroURmqH5w2A] <http://www.linkedin.com/pub/rob-ward/45/42a/bb4> | Twitter: @reptile_rob<https://twitter.com/reptile_rob> / @ThinkGrassSnake<https://twitter.com/ThinkGrassSnake> | Web: www.ThinkGrassSnake.Je<http://www.thinkgrasssnake.je/>


	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list