Lesson 3 of 34
In Progress

mapview for Quick Maps (01_03)

Learn More

As noted in the video, the mapview package does provide advanced customizability for the maps created. However, it’s recommended that you instead focus on using the leaflet package for publication-quality level interactive maps (the third section of this course). You can find the mapview package documentation here.

Have any questions? Put them below. David or Charlie Hadley will help you out!

    1. Hi Perry! In this course I chose to cover only one option for static and interactive maps. I prefer {ggplot2} because it’s more widely used than {tmap}, and it also has an extensive collection of packages that extend its capabilities. Here are some useful extensions when it comes to maps:

      On top of this, the {cowplot} and {patchwork} packages are both designed for assembling multiple {ggplot2} charts together – which includes maps built using geom_sf().

      However, I do recognise that {tmap} is very powerful and can be used to create beautiful maps. Because it is designed specifically with mapping in mind it often takes less code to do things in {tmap} vs {ggplot2}.

  1. Hello,
    I am having problems with the instalation of ‘mapview’. First, I install the package (install.packages(“mapview”)) and it works, but when I say ‘library(mapview)’ RStudio chrases and stop working. What could be the problem?
    Thank you.

    1. Hi Irantzu, sorry this is happening. Could you tell me a little bit about your set up:

      • What OS are you running
      • Could you run `version` in the R console and paste what appears – I’ve given an example below
      • Could you get the current version of RStudio by going to Help > About RStudio

      Example R version output

      > version
      platform x86_64-apple-darwin17.0
      arch x86_64
      os darwin17.0
      system x86_64, darwin17.0
      major 4
      minor 1.1
      year 2021
      month 08
      day 10
      svn rev 80725
      language R
      version.string R version 4.1.1 (2021-08-10)
      nickname Kick Things

      1. Hi Charlie,
        Thank you very much for your reply. Here ther versions:
        – OS: Windows 10.
        – R version:
        > version
        platform x86_64-w64-mingw32
        arch x86_64
        os mingw32
        system x86_64, mingw32
        major 4
        minor 0.2
        year 2020
        month 06
        day 22
        svn rev 78730
        language R
        version.string R version 4.0.2 (2020-06-22)
        nickname Taking Off Again

        – RStudio version: Version 1.3.1073

        Thank you,

        1. Thanks, Irantzu.

          Your RStudio is fairly old, and I know that has caused issues for some packages like {mapview}. I’d recommend installing the latest version of RStudio and seeing if that fixes it.

          If the problem remains the next thing I’d try is updating R. However, you’ll need to reinstall your packages afterwards.

          If you continue to have the issue after upgrading both R and RStudio it’s likely there’s a bug and we should try and capture info about your system to help the package developer fix the bug. Could you comment again if you continue to have this issue? Thanks, Charlie

  2. Hi,
    I might be missing something. All map effects below, do show up in viewer pane of my RStudio.
    The map effects at:
    2:56 and 4:00 (colored map of countries)
    4:12 (pop-up menu upon clicking),
    4:56 (rings around tiny countries) and
    5:32 (colored map of states with the US).
    I will appreciate any assistance.

    Thank you!!.

    1. Hello Latif. I’m sorry I didn’t quite understand your question, could you help me? Is the problem that the mapview maps are not showing at all for you? Are the maps showing in a separate window or your browser instead? Thanks, Charlotte.

      1. Sorry for the mix up. I meant to say. “All the map effects below, do *not* show up in viewer pane of my RStudio.”

        *The maps do show up*. However, my visuals differ from those in the lesson clip. For instance, the blue colored map of countries at 2:56 and 4:00 do not appear. At 4:12, a pop-up menu appear in the lesson video upon clicking (on Antarctica). I can’t get the menu to show.
        Also, I do not see the rings around tiny countries at 4:56 and the colored map of states with the US at 5:32.

        I hope my question is clearer now.🙏🏾

        1. Hi Latif – thanks for coming back with more information. I wonder if you’ve got an older version of RStudio and that’s the issue. Could you try to update RStudio and see if {mapview} continues to not show the data layers?