I am trying to plot interactive maps at the NUTS3 level. Initially I was using shapefiles that I constructed myself for the data in QGIS, however, when I tried to use them in R they rendered poorly with lines or even entire polygons being warped out of place/shape. I then tried using the shapefiles provided by Eurostat directly (which my shapefiles were large based off of) using the Eurostat package, however, when I plot the map there are still lines/polygons that are being warped out of position (different ones from those of my original shapefiles, however).
I have what I believe should be a reproducible example showcasing the issue below:
# Get relevant NUTS3 shapefile from Eurostat
NUTS3EU <- get_eurostat_geospatial(output_class = "df", resolution = "60")
# Generate random number vector
x <- rnorm(n = nrow(NUTS3EU), mean = 1)
# Merge random number vector into data as new variable 'RandVar'
NUTS3EU$RandVar <- x
# Subset data down to just Germany NUTS3 level
deuNUTS <- NUTS3EU[(NUTS3EU$CNTR_CODE == "DE"),]
deuNUTS <- deuNUTS[(deuNUTS$LEVL_CODE == 3),]
# Generate ggplot object
userMap2 <- ggplot(deuNUTS, aes(long, lat, group = NUTS_ID, fill = RandVar, data_id = NUTS_ID, tooltip = id)) + geom_polygon_interactive(colour = "white", size = 0.3)
# Generate Girafe interactive plot object
ggiraph(ggobj = userMap2, tooltip_offy = -20, zoom_max = 3)
# Output should be map of Germany with small number of lines/polygons being warped, may need to zoom in to see the issue
I understand that the 'order' variable is important and have made sure it is correctly sorted, but the issue persists.
How can I make the plot geographically correct?
If I need to use a different source for the shapefile that is fine as long as it is accurate.
get_eurostat_geospatial
can get them insf
format which is a spatial format designed for mapping?