Social Analytics and Strategic Intelligence
Session 2: Maps
library(sf)
## Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
library(ggplot2)
library(rio)
library(sf)
#Import
dat="https://github.com/Pepix2345/introgeodf/raw/main/maps/worldMap.gpkg"
sf:: st_layers(dat)
## Driver: GPKG
## Available layers:
## layer_name geometry_type features fields crs_name
## 1 countryBorders 252 1 WGS 84
## 2 riverLines 98 2 WGS 84
## 3 cityPoints Point 610 3 WGS 84
Exercise 1
countries= read_sf(dat, layer="countryBorders")
rivers= read_sf(dat, layer="riverLines")
cities= read_sf(dat, layer="cityPoints")
basemap=ggplot(data=countries) + geom_sf(fill='gray98') + theme_light()
finalmap=basemap + geom_sf(data=rivers, color='skyblue') + geom_sf(data=cities, color='aquamarine')
finalmap

Exercise 2
#Import
dat2= "https://github.com/Pepix2345/introgeodf/raw/main/maps/Perumap.gpkg"
sf:: st_layers(dat2)
## Driver: GPKG
## Available layers:
## layer_name geometry_type features fields crs_name
## 1 Peruborders Polygon 1 1 WGS 84
## 2 Perupoints Point 8 3 WGS 84
## 3 Perulines 5 2 WGS 84
Peru= read_sf(dat2, layer= "Peruborders")
Peru_cities= read_sf(dat2, layer= "Perupoints")
Peru_rivers= read_sf(dat2, layer= "Perulines")
basePeru= ggplot(data= Peru) + geom_sf(fill= 'gray98') + theme_light()
finalPeru= basePeru + geom_sf(data= Peru_cities, color= 'aquamarine') + geom_sf(data= Peru_rivers, color= 'skyblue')
finalPeru

Exercise 3
#Import
dat3="https://github.com/Pepix2345/introgeodf/raw/main/maps/Peru24891.gpkg"
sf:: st_layers(dat3)
## Driver: GPKG
## Available layers:
## layer_name geometry_type features fields crs_name
## 1 country Polygon 1 1 PSAD56 / Peru west zone
## 2 cities Point 8 3 PSAD56 / Peru west zone
## 3 rivers 5 2 PSAD56 / Peru west zone
## 4 airports Point 204 7 PSAD56 / Peru west zone
`
peru= read_sf(dat3, layer= 'country' )
peru_airports= read_sf(dat3, layer= 'airports')
graph= ggplot(data= peru) + geom_sf(fill= "gray98") + theme_light()
graph2= graph + geom_sf(data= peru_airports, color= "darkorchid1")
graph2

Social Analytics and Strategic Intelligence
Session 2: Maps
Exercise 1
Exercise 2
Exercise 3
`