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
Converting Addresses to Coordinates (01_09)
This lesson is locked
This lesson is called Converting Addresses to Coordinates (01_09), part of the Mapping with R course. This lesson is called Converting Addresses to Coordinates (01_09), part of the Mapping with R course.
If the video is not playing correctly, you can watch it in a new window
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_09
project. In the your-turn.R file:
Convert the addresses in the “International Addresses” worksheet into coordinates and visualise them.
Import the “International Addresses” worksheet
Re-use the
mutate(across(...))
code to remove NA valuesCombine together
address_line_1
,address_line_2
,address_line_3
intofull_address
Use
geocode()
to convert the addresses into coordinatesVisualise the locations with
mapview
Learn More
This video introduces two packages for forward geocoding, which I’d like to summarise again here:
ggmap
uses the Google Maps Geocoding API which is extremely well regarded and considered an industry standard. However, to register for the API you must provide your credit card details to Google. As of late 2020 users are provided with $300 free credit per month, however this could change in the future. Instructions for setting up your Google Cloud Platform account can be found on the ggmap
package website.
tidygeocoder
provides access to four different geocoding API via the method
argument:
“census” is the default and connects to the free to use US Census Geocoder but is only useful for addresses in the US
“osm” uses the entirely free Nominatim geocoding service from OpenStreetMaps but is explicitly not suitable for commercial or bulk geocoding
“geocodio” uses the commercial geocoding service Geocodio that covers only the US and Canada. A free tier is available and you do not need to provide your billing details for this type of account.
“iq” uses the international commercial geocoding service LocationIQ. A free tier is available and you do not need to provide your billing details for this type of account.
It’s important to remember that there is (unfortunately) not an international standard for formatting street addresses. In general, the more specific a query the more likely an API will return an accurate set of coordinates.
You need to be signed-in to comment on this post. Login.
Kristina Bratkova
March 2, 2022
Hello, I was wondering whether the order of arguments in geocode() function matters (i.e. whether we specify
street= street_address, city = city, postalcode = postal_code,
in this order or different one)? I was also wondering whether adding more columns to geocode() that have many NAs like state=region may prevent from finding the addresses (for example, iq method found all 11 addresses each time but without the method specified, geocode found only 4 addresses with state=region argument (plus all other column as in the example) but excluding this argument geocode found 9 addresses; this question may be related to the first one perhaps?Kristina Bratkova
March 4, 2022
Hi David and Charlie,
many thanks for your replies. Charlie, yes correct, the 'osm' (default) method found 9 addresses out of 11 but only 4 with state=region argument (as it has fussy NAs as you explain). 'iq' method found all 11 in both instances.
Great course so far!
Jeremy Danz
February 13, 2023
Are there regional differences or any other settings that would influence which values are returned for the fragmented address information we're starting with? Following this code exactly never found coordinates for the American University in Cairo, for example, and the map I've produced seems to think the Harbin University of Science and Technology is in Italy!
In the instructions for the "Your Turn" section, it mentions combining three lines of the address into full_address, and using mutate(across(...)) to remove NA values, but these steps don't seem to be mentioned in the solutions video or the solutions code chunk. Did I miss something there?
Thanks!! The course is awesome, I'm having a lot of fun :)