I am trying to assign a region ID to each record within a point shapefile. Each point would be assigned the Region ID of the region it falls within. The point feature is called "deciles" and the region/polygon feature is "regions". I keep getting this error:

Error in UseMethod("inner_join") : no applicable method for 'inner_join' applied to an object of class "c('SpatialPointsDataFrame', 'SpatialPoints', 'Spatial')"

deciles<- readOGR("C:\\filepath", "deciles")
regions<- readOGR("C:\\filepath", "regions") 
#Assign each bsu to a region with a spatial join
bsu_regions_join <- inner_join(deciles, regions, by = region_ID)

I've also tried these variants and I still get the same error:

bsu_regions_join <- st_join(deciles, left = FALSE, regions["region_ID"])
bsu_regions_join <- st_join(deciles, left = FALSE, regions) 
bsu_regions_join <- st_join(regions, deciles, left = FALSE)

You are reading your files in with rgdal. Read them in with sf (st_read) then you can apply an sf operation like st_join to it. Or change your objects from Spatial Point/Polygons dataframe to sf objects using st_as_sf(deciles) and st_as_sf(regions) and then apply st_join to it.

  • Thank you so much! Worked like a charm!
    – bkGeog
    Feb 17 '20 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.