Geographic Coordinate
Geographic coordinate uses latitude and longitude to locate a position. Latitude and longitude are just like x-y axes, so you can build all kinds of graphs with them, like Scatterplot and Density Contour Plot.
- In a geographic coordinate, latitude comes first. But it is the north-south direction. Therefore, there is a cross between lat-long and x-y coordinates.
There are also some special graphs for geographic coordinate system, but with controversial performance, like
- Radius Map: use a circle with a radius dependent on an additional variable to represent a dot
- Push Pin Map: use a push pin icon to represent a dot
Implementation
ggmap
Package ggmap can generate real-world maps. It is compatible with ggplot2, so you can easily add layers on top of the base map. Related functions:
get_stamenmap: get a US map- can be zoomed using option
bbox,zoom, and the latitude-longitude range of the area
- can be zoomed using option
get_googlemap: get the map of the specified latitude-longitude range from Google mapggmap: render the map
sf and tmap
sf and tmap
R Package
sfis for reading shape files (.shp). To see the read map, use functionst_geometry()and plot the returned object.R Package
tampis for plotting maps (generated bysf) together with other data. The general workflow isLink to original
- Get the spatial data by reading the shape file using
sf- Combine spatial data and other data
- e.g. use
left_join()- plot the combined data using
tmap