This is a fun lesson using R to draw maps based on coordinates from googlemaps.
To draw a map in R using coordinates
tidyverse
leaflet
I can find the coordinates from googlemaps and use them to draw the map in R
Go to googlemaps on the internet. Search for Green Oak Academy. Right click on the red dot which shows the location of the school. This should show you the coordinates. Click on the coordinates to copy them to the clipboard.
Paste the coordinates here
latitude:
longitude:
(Hint: The longitude coordinate will be a negative number)
Now carefully copy and paste the latitude and longitude readings into the correct place in code chunk1 replacing the zeroes.
Run the code chunk by clicking on the little arrow on the right of the chunk.
Can you see the school on the map?
Now copy and paste the school’s coordinates into chunk2 replacing the zeroes.
Run the code. Can you see the school?
leaflet() %>%
setView(lat = 00000, lng = 00000, zoom = 16) %>%
addProviderTiles(providers$Esri.WorldImagery)
How are the two maps different?
Answer:
Knit your document and check your output file.
Copy and paste the R code from chunk2 into chunk3.
Replace the coordinates with the following
latitude: 21.424931139508526 longitude: 39.82589497119249
Run the code. What do you see? Answer:
Knit your document and check the output file.
Use googlemaps to find the coordinates of Al Masjid an Nabawi.
Copy the code chunk from chunk3 into chunk4 and replace the coordinates with Al Masjid an Nabawi’s coordinates
Use googlemaps to find the coordinates of Al-Aqsa Masjid, Jerusalem.
Copy the R code chunk from chunk3 into chunk4 and replace the coordinates with Al-Aqsa Masjid’s coordinates.
KNIT YOUR DOCUMENT for the final time. Your teacher will check your work in the final knitted document.
License and Citation: You can use, modify, and adapt any of the lessons, but please include the following attribution: RGirls Community. (2022, April 10). RGirls Lessons. Zenodo. https://doi.org/10.5281/zenodo.6436861