
Assign polygons in one spatvector to polygons in another spatvector, based on greatest overlap
Source:R/assign_polygons.R
assign_polygons.RdRather than identifying all intersecting polygons, this function identifies the polygon in 'y' that is associated with the greatest overlap of each polygon in 'x'.
Examples
if (FALSE) { # \dontrun{
poly<-get_shapefile('oecm')
naf<-get_shapefile('nafo.clipped')
naf<-project(naf,poly)
x<-crop(poly,naf)
x<-x[,1]
y=naf[,1]
test<-assign_polygons(x,y)
test
ggplot()+
geom_spatvector(data=test[which(test$Label%in%c('4T','4S')),],aes(fill=Label))+#,col=NA
geom_spatvector(data=naf,fill=NA)
} # }