I used raster::getData
to obtain a Large SpatialPolygonsDataFrame
details below
states <- raster::getData("GADM", country = "United States", level = 1
I subsetted IL and WI...
statesilwi <- states[states$NAME_1 == "Illinois" | states$NAME_1 == "Wisconsin",]
But when I plot it, it Illinois looks a little bit funky, why is this happening and is there a way to fix it?
plot(statesilwi)
"looks a bit funky" is not very clear. But it seems to me that @rawr is correct. A part of Lake Michigan belongs to Illinois.
You can remove Lake Michigan like this:
library(terra)
library(geodata)
us <- geodata::gadm("United States", level = 2, path=".")
us <- us[us$TYPE_2 != "Water body", ]
s <- us[us$NAME_1 %in% c("Illinois", "Wisconsin"),]
s <- aggregate(s, "NAME_1")
plot(s)