0

I need the map of the lombardy region, in Italy.

When I run map("italy") however I can see that the dataset is divided at the province level, not the regional one. Lombardy is composed by 12 provinces. I can get the map of Milan (city and province) by doing map("italy","Milan") but it gives me an error when I do map("italy","Lombardy").

My question is: how can I put in one map multiple provinces (those in the region of Lombardy)? Is it possible to delete the internal borders?

GGamba
  • 11,599
  • 2
  • 35
  • 38
Pigna
  • 2,322
  • 3
  • 21
  • 44

1 Answers1

2

From the maps help:

This italy database comes from the NUTS III (Tertiary Administrative Units of the European Community) database of the United Nations Environment Programme (UNEP) GRID-Geneva data sets. These were prepared around 1989, and so may be somewhat out of date.

Back then Lombardy had only 10 provinces, so we'll use those.

library(maps)

lombardy_provs <- map('italy', c('Milan', 'Bergamo', 'Brescia', 'Como', 
                                 'Cremona', 'Lecco', 'Mantova', 'Varese', 
                                 'Pavia', 'Sondrio'), 
                      resolution = 0)

The resolution = 0 argument is used to get the maximum resolution available, otherwise we'll get artifacts down the line.

We use the new sf (simple features) package to union these regions.

First we cast the map object to a sf

library(sf)
#> Linking to GEOS 3.5.0, GDAL 2.1.1, proj.4 4.9.3

lombardy_sf_provs <- st_as_sf(lombardy_provs)
plot(lombardy_sf_provs)

Then we can 'union' them using st_union()

lombardy_sf <- st_union(lombardy_sf_provs)
plot(lombardy_sf, col = 'lightblue')

Imo the sf format is more suitable for any use than the maps format, YMMV.

GGamba
  • 11,599
  • 2
  • 35
  • 38
  • Thanks @GGamba, that looks great! However when I try to install sf I get this error: `configure: error: sf is not compatible with GDAL versions below 2.0.0`. How can I upgrade this software GDAL? I have version 1.10.1 and I am on ubuntu 14.04 – Pigna Jul 10 '17 at 18:10
  • 1
    `GDAL` is at that version for stable *unix. I'm actually upgrading it right now on a new Linux machine, using the code [here](https://askubuntu.com/questions/823023/gdal-install-failing-on-ubuntu-16-04-lts). I'll see how it goes – GGamba Jul 10 '17 at 18:31
  • I ended up the hints from [this page](https://github.com/r-spatial/sf/blob/593ee48b34001fe3b383ea73ea57063ecf690732/.travis.yml) @gboffi You are right, Lecco wasn't there yet :) – GGamba Jul 10 '17 at 20:20
  • I am sorry @GGamba , I am a little confused. All of those instructions are to be put in the terminal? Or are there some steps to be done in R? – Pigna Jul 11 '17 at 22:24