Hey guys,
I've just tried to replicate some code I ran about 3 months ago, which ran all fine back then, but I'm having issues with it now. I'm trying to add covariates to a mask using an sf object (geometry type multipolygon), and for the points in mask to take the value of the polygon.
> head(maskprac23)
x y
553 424176.1 6381869
554 424631.5 6381869
555 425086.8 6381869
643 424176.1 6382324
644 424631.5 6382324
645 425086.8 6382324
> head(AllAllKdesf23)
Simple feature collection with 6 features and 4 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 419153.3 ymin: 6381033 xmax: 455351.5 ymax: 6410638
Projected CRS: WGS 84 / UTM zone 56S
id area CollarPack TerritoryZone geometry
homerange homerange 181.26689 JB Core MULTIPOLYGON (((422644 6383...
homerange1 homerange 69.59331 WT Core MULTIPOLYGON (((423088.1 63...
homerange2 homerange 1718.65294 SL Core MULTIPOLYGON (((425709.4 63...
homerange3 homerange 1817.93157 MB Core MULTIPOLYGON (((433811 6398...
homerange4 homerange 176.76953 YG Core MULTIPOLYGON (((454276.1 64...
homerange5 homerange 1294.93712 JB Periph MULTIPOLYGON (((423964.6 63...
> maskprac23 <- addCovariates(maskprac23,AllAllKdesf23)
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 818, 1004
In addition: Warning message:
In addCovariates(maskprac23, AllAllKdesf23) :
missing values among new covariates
> nrow(AllAllKdesf23)
[1] 10
As you can see it's coming up with '1004' rows for the spatial object, but it only has 10 polygons. It looks to me like it's trying to take the values as if they are the same points and extract for each row, rather than trying to take the value from the polygon. Do you think this is an issue with the package being updated? There will be a few missing values with the covariates (the warning message), I don't think that is the issue.
As I say, I'm using exactly same datasets as before and code all ran OK then. Any help would be much appreciated!! Apologies if I've missed something obvious.
Thanks,
Brendan