I am trying to create a convex hull for a set of spatial points and then later crop a raster by the extent of this polygon.
coords<-as.data.frame(cbind(dnlocs_1949$decimalLongitude,dnlocs_1949$decimalLatitude))
dn_1949 <- SpatialPointsDataFrame(coords,
dnlocs_1949,
coords.nrs = numeric(0),
proj4string = CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
pts_1949<-as(dn_1949,"sf")
hull_1949<- st_convex_hull(st_union(pts_1949))
##this created a visual convex hull but does not have the information to save as a polygon
##it saves hull_1949 has a list
#then when i try crop my raster
temp_1940<-crop(x=temp_1940, y=hull_1949)
#i get the error message
#Error in (function (classes, fdef, mtable) :
#unable to find an inherited method for function ‘extract’ for signature ‘"RasterLayer", "sfc_POLYGON"’