L11: Fundamentals of Mapping

Points, Lines, Polygons, and Choropleth Maps

Bogdan G. Popescu

John Cabot University

Mapping

Previously, we looked at using ggplot to plot different objects

We will go over mapping objects once again.

Mapping

First, download all the files and put them in the relevant folder:

Your folder

This what they should look like on your computer.

Your folder

Note that selection.gdb and world_shp should be separate folders

Your folder

Note that selection.gdb and world_shp should be separate folders

Mapping

We will first map points, lines, and polygons

We will then map then together

We will then make a map that is visually appealing and which contains a variety of elements and options

Mapping

This is how we first read our data:

#Step1: Loading the libraries
library(sf)
library(ggplot2)

#Step2: Reading the lines
gis_osm_roads <- st_read(dsn="./data/selection.gdb",
                         layer="gis_osm_roads", quiet = T)

#Step3: Reading the polygons
gis_buildings <- st_read(dsn="./data/selection.gdb",
                         layer="gis_osm_buildings", quiet = T)

#Step4: Reading points
restaurants <- st_read("./data/restaurant.geojson", quiet = T)
restaurants<-subset(restaurants, select = c(name, addr.street))
restaurants2<-subset(restaurants, !is.na(restaurants$name) | !is.na(restaurants$addr.street) )

Mapping lines

ggplot()+
  geom_sf(data=gis_osm_roads)

Mapping polygons

ggplot()+
  geom_sf(data=gis_buildings)

Mapping points

ggplot()+
  geom_sf(data=restaurants2)