0

I was able to build this map with data from the Eurostat

enter image description here

As I am working in Spanish, the legend should be in this language nevertheless, in the legend still appears two words in English (under and over) which I am not able to modify (honestly I do not know how to do it or where part of the code should I modify). The other issue is that the map is too small and I'd like to make it bigger and the islands showed are so far that make the map with a lot of blanks spaces. Is there any way to make this islands closer or omit them?

I also post the code if anyone wants to work with it.

library(rgdal)
library(RColorBrewer)
library(sp)
library(GISTools)
library(classInt)
library(maptools)
library(SmarterPoland)
library(reshape)
library(reshape2)

setwd("yourdirectory")

EU_NUTS <- readOGR(dsn = "yourdirectory/NUTS_2010_60M_SH/data", layer = "NUTS_RG_60M_2010")
plot(EU_NUTS)

proj4string(EU_NUTS)

EU_NUTS <- spTransform(EU_NUTS, CRS("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"))

plot(EU_NUTS)

EurostatTOC <- getEurostatTOC()

head(EurostatTOC)

data <- getEurostatRCV(kod = "demo_r_frate2")

unique(data$age)
unique(data$time)

sub_data <- subset(data, (age == "Y_GE50") & (time == "2016 "))

mapdata <- cast(data, geo ~ time + age)

head(mapdata)

head(EU_NUTS@data)

EU_NUTS@data = data.frame(EU_NUTS@data, mapdata[match(EU_NUTS@data[, "NUTS_ID"], mapdata[, "geo"]), ])

my_colours <- brewer.pal(5, "BuGn")

breaks <- classIntervals(EU_NUTS@data$X2016_TOTAL, n = 5, style = "fisher",  unique = TRUE)$brks

plot <- plot(EU_NUTS, col =my_colours[findInterval(EU_NUTS@data$X2016_TOTAL,  breaks, all.inside = TRUE)], axes = FALSE, border = NA)
CountryBorder <- EU_NUTS[EU_NUTS@data$STAT_LEVL_ == 0, ]
plot <- plot(CountryBorder, border = "#707070", add = TRUE)

plot <- legend(x = -6080915, y = 8730220, legend = leglabs(round(breaks, digits = 2), between = " a <"), fill = my_colours, bty = "n", cex = 0.7, title = "Tasa de fertilidad")
plot <- plot(EU_NUTS, col = my_colours[findInterval(EU_NUTS@data$X2016_TOTAL, breaks, all.inside = TRUE)], axes = FALSE, border = NA)
plot <- plot(CountryBorder, border = "#707070", add = TRUE)
plot <- legend(x = -6080915, y = 8730220, legend = leglabs(round(breaks,  digits = 2), between = " a <"), fill = my_colours, bty = "n", cex = 0.7, title =  "Tasa de fertilidad")
title("Tasa total de fertilidad en regiones EU NUTS-2\nNúmero de hijos por mujer en 2016")
4
  • Those are not islands, but part of South America (and France) for example. Try adding the rest of the world
    – Ian Turton
    Aug 30, 2018 at 17:50
  • I just need Europe.
    – José
    Aug 30, 2018 at 20:06
  • see answers to a similar question . Answers are not in R but the procedure should work the same to remove outlying territories (it's probably possible in just R, too)
    – Steven Kay
    Aug 30, 2018 at 20:06
  • Sorry but I am unable to find the link between the qgis, d3-geo and R.
    – José
    Aug 30, 2018 at 20:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.