Get access to all lessons in this course.
- Welcome to Mapping with R (01_01)
-
Geospatial Data
- Making Maps is Complex (01_02)
- mapview for Quick Maps (01_03)
- sf for Simple Features (01_04)
- Turning Data Frames into sf Objects (01_05)
- Importing Shapefiles (01_06)
- Joining Geospatial Datasets (01_07)
- Disambiguating Country Names (01_08)
- Converting Addresses to Coordinates (01_09)
- U.S.-Specific Datasets (01_10)
- Advice on Finding International Datasets (01_11)
- CRS and Projections: Geographic and Projected CRS (01_12)
- CRS and Projections: How to Choose a CRS (01_13)
- Introducing Raster GIS with raster and stars (01_14)
- Basics of Using the raster Package (01_15)
-
Static Maps
- ggplot2 Essentials (02_01)
- Starting a Map in ggplot2 (02_02)
- Labelling ggplot2 Maps (02_03)
- Compare Locations/Events with Geobubble Charts (02_04)
- Highlight a Region in a Country with ggplot2 (02_05)
- Make a Choropleth Map of Discrete Variables with ggplot2 (02_06)
- Make a Choropleth Map of Continuous Variables with ggplot2 (02_07)
- Faceting Choropleth Maps with ggplot2 (02_08)
- Visualize Raster Data with ggplot2 (02_09)
- Adding Scale Bars and North Arrows with ggplot2 (02_10)
-
Interactive Maps
- What is leaflet? (03_01)
- Starting a Map in leaflet (03_02)
- Necessary HTML for Labelling leaflet Maps (03_03)
- Highlight a Region in a Country with leaflet (03_04)
- Compare Locations/Events with Geobubble Charts in leaflet (03_05)
- Make a Choropleth Map of Discrete Variables with leaflet (03_06)
- Make a Choropleth Map of Continuous Variables with leaflet (03_07)
- Visualize Raster Data with leaflet (03_08)
-
Wrapping Up
- You Did It!
Mapping with R
sf for Simple Features (01_04)
This lesson is locked
This lesson is called sf for Simple Features (01_04), part of the Mapping with R course. This lesson is called sf for Simple Features (01_04), 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.
Your Turn
Open the 01_04.Rproj file in order to open the appropriate project. From there:
Use mapview()
to visualise only the regions in tiny_countries110
where the UN region is either “Seven Seas (open ocean)” or “Oceania”.
Load the {tidyverse}, {mapview}, {rnaturalearthdata} and {sf} packages
Convert
tiny_countries110
into an sf objectFilter only those countries in “Seven Seas (open ocean)” or “Oceania”
Visualise this object with {mapview}
Learn More
If you want to learn more about how the sf
package handles simple features data visit its website. Please note that it can do a lot of complex geospatial analysis, most of which is not covered in this course. If you want to learn about doing this type of work, check out Geocomputation with R.
The video demonstrates how to work with objects that have the class “sf” “data.frame” because they work just like normal data.frames. Sometimes you’ll need to work with the lower-level geometry objects but this is rare.
You need to be signed-in to comment on this post. Login.
Latif Apaassongo Ibrahim
February 19, 2022
Similar to my previous concern, I think I can only visualize the basemaps but not any map features. When I use codes in the example files, I can see country but not county boundaries. I can neither see the blue colored polygons in the videos nor interact with the output. I am using R version 4.1.2 (2021-11-01) -- "Bird Hippie". Could that be the problem?
Tyler Kelly
March 5, 2022
I am having the same issue. The county polygons are not showing up.
Charlie Hadley
March 7, 2022
Hello Tyler. Could you update RStudio and see if this resolves the issue?
Tyler Kelly
March 11, 2022
Hi Charlie, sadly no it hasn't.
Charlie Hadley
March 7, 2022
Hi Latif, did this issue resolve by updating RStudio?
Ochiagha Ananaba
June 17, 2022
I have the same issues where base map is showing but not the boundaries. I am using R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Ochiagha Ananaba
June 17, 2022
Included mapviewOptions(fgb = FALSE) in my code and it worked
Charlie Hadley
June 20, 2022
Hello! Sorry this isn't working for you, there are some known issue with {mapview}. Could you try the following?
To give you some context, the {mapview} package is developed on GitHub and "the known issue" is this page - https://github.com/r-spatial/mapview/issues/413.
Please let me know if this doesn't work.
Cheers,
Charlie
Oscar Tetteh
March 29, 2023
Hi
Please, my data is now showing in the global environment.
It says: Error in counties_sf("laea") : could not find function "counties_sf"
David Keyes
March 29, 2023
Can you share your full code please?
Hannah Ridenour LaFrance
July 17, 2023
Hi, I've been unsuccessful at installing the albersusa package, being told that "there is no package called "albersusa"" - I'm running on R 4.3.1 and RStudio 2023.06.1+524 "Mountain Hydrangea" Release (547dcf861cac0253a8abb52c135e44e02ba407a1, 2023-07-07) for windows Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36
David Keyes
July 17, 2023
You should be able to install it with this code:
You'll need to install the remotes package using install.packages("remotes") first (if you don't already have it installed). Let me know if that works!
Hannah Ridenour LaFrance
July 18, 2023
Success! Turns out my issue was not having git installed...I got a new laptop a few months ago and have slowly been rediscovering all the setup items I need to redo. I'm very grateful to the archived R in 3 Months videos to refer back to in these moments!