mapview for Quick Maps (01_03)
This lesson is called mapview for Quick Maps (01_03), part of the Mapping with R course. This lesson is called mapview for Quick Maps (01_03), part of the Mapping with R course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
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 and we will help you out!
Course Content
34 Lessons
1
Making Maps is Complex (01_02)
09:15
2
mapview for Quick Maps (01_03)
06:41
3
sf for Simple Features (01_04)
15:03
4
Turning Data Frames into sf Objects (01_05)
09:41
5
Importing Shapefiles (01_06)
07:59
6
Joining Geospatial Datasets (01_07)
10:30
7
Disambiguating Country Names (01_08)
08:23
8
Converting Addresses to Coordinates (01_09)
19:50
9
U.S.-Specific Datasets (01_10)
17:35
10
Advice on Finding International Datasets (01_11)
09:41
11
CRS and Projections: Geographic and Projected CRS (01_12)
12:33
12
CRS and Projections: How to Choose a CRS (01_13)
13:20
13
Introducing Raster GIS with raster and stars (01_14)
05:35
14
Basics of Using the raster Package (01_15)
02:37
1
ggplot2 Essentials (02_01)
20:17
2
Starting a Map in ggplot2 (02_02)
06:31
3
Labelling ggplot2 Maps (02_03)
16:05
4
Compare Locations/Events with Geobubble Charts (02_04)
10:29
5
Highlight a Region in a Country with ggplot2 (02_05)
13:46
6
Make a Choropleth Map of Discrete Variables with ggplot2 (02_06)
14:59
7
Make a Choropleth Map of Continuous Variables with ggplot2 (02_07)
08:43
8
Faceting Choropleth Maps with ggplot2 (02_08)
07:39
9
Visualize Raster Data with ggplot2 (02_09)
07:59
10
Adding Scale Bars and North Arrows with ggplot2 (02_10)
02:10
1
What is leaflet? (03_01)
04:42
2
Starting a Map in leaflet (03_02)
08:09
3
Necessary HTML for Labelling leaflet Maps (03_03)
12:41
4
Highlight a Region in a Country with leaflet (03_04)
08:57
5
Compare Locations/Events with Geobubble Charts in leaflet (03_05)
10:57
6
Make a Choropleth Map of Discrete Variables with leaflet (03_06)
13:36
7
Make a Choropleth Map of Continuous Variables with leaflet (03_07)
09:40
8
Visualize Raster Data with leaflet (03_08)
11:13
You need to be signed-in to comment on this post. Login.
perry carter • February 12, 2022
What about tmap?
Irantzu Alvarez • February 14, 2022
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.
Latif Apaassongo Ibrahim • February 17, 2022
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!!.
Charlie Hadley • April 1, 2022
I'm glad it's working now!
Laura Coleman • October 29, 2022
I am having issues downloading the albersusa package from github. Here is the error that I receive: > remotes::install_github("hrbrmstr/albersusa") Downloading GitHub repo hrbrmstr/albersusa@HEAD Error in utils::download.file(url, path, method = method, quiet = quiet, : cannot open URL 'https://api.github.com/repos/hrbrmstr/albersusa/tarball/HEAD'
Is there a different way to install this package?
Jeremy Danz • February 13, 2023
Hi Charlie - when trying to run alaska_landcover %>% mapview()
I got 2 error messages. The first said something about max pixel size and seemed to include a suggested solution in the error message, so I added maxpixels = 7194132, and that portion of the error isn't appearing.
However, I'm still getting this message and the map of Alaska is not loading: Error in
levels<-
(*tmp*
, value = as.character(levels)) : factor level [3] is duplicatedAny ideas on this one? Thanks!!
Duncan McDonnell • December 29, 2023
Hi Charlie - I get this error when I try to install "albersusa":
ERROR: dependencies ‘rgeos’, ‘rgdal’, ‘maptools’ are not available for package ‘albersusa’
What is it about? Thanks for your help!
David Keyes Founder • January 2, 2024
Hi Duncan! So, unfortunately, this is an issue because the
rgeos
,rgdal
, andmaptools
packages were archived from CRAN. I'm checking with Charlie about the best approach here. I will say that you can do nearly the same thing with thetigris
package using this code:The
shift_geometry()
function comes from thetigris
package and makes it easier to see Alaska, Hawaii, and Puerto Rico.David Keyes Founder • January 5, 2024
Quick update: Charlie says the best way is to use the
tigris
package in the way I shared. Hope that helps!Andrew Paquin • April 5, 2024
I'm having a lot of trouble with this (many of the same issues noted by others):
levels<-
(*tmp*
, value = as.character(levels)) : factor level [3] is duplicated In addition: Warning message: In rasterCheckSize(x, maxpixels = maxpixels) : maximum number of pixels for Raster* viewing is 5e+05 ; the supplied Raster* has 7194132 ... decreasing Raster* resolution to 5e+05 pixels to view full resolution set 'maxpixels = 7194132 'David Keyes Founder • April 8, 2024
Ok, finally getting back to you on this.
I'm glad my updated code worked.
Unfortunately, the
raster
package no longer works as shown in the video. There have been a lot of changes in the geospatial world in R in recent years. The package that has supersededraster
is calledterra
. You can install it withinstall.packages("terra")
and then run this updated code to make this work:However, if you aren't using raster data (and I doubt you are), I wouldn't even worry about it. For most people, vector data is what they work with when making maps.
mapview()
function changed when you want to display multiple layers. Instead of:You now need:
I'm sorry about these issues. We're working on getting them updated in the course.