Section 19 Mapdeck

key<-"pk.eyJ1IjoiZGdvbGljaGVyIiwiYSI6ImNqdThpbHFobDF5dDQ0NHRhNmlyeGIxOGgifQ.Intjo4_tKHPfznud_gBEmw"

library(mapdeck)
set_token(key)
crash_data = read.csv("https://git.io/geocompr-mapdeck")
crash_data = na.omit(crash_data)
ms = mapdeck_style("light")
mapdeck(style = ms, pitch = 45, location = c(0, 52), zoom = 4) %>%
add_grid(data = crash_data, lat = "lat", lon = "lng", cell_size = 1000,
         elevation_scale = 50, layer_id = "grid_layer",
         colour_range = viridisLite::plasma(6))
require(RPostgreSQL)
require(rpostgis)
require(sf)
require(mapview)
require(tmap)
conn <- dbConnect("PostgreSQL", host = "postgis",
  dbname = "gis_course" ,user = "docker", password = "docker")
query<-"create extension plr"
dbSendQuery(conn,query)

query<-"CREATE OR REPLACE FUNCTION test_plr()
RETURNS text AS $$
install.packages('sf', repos='http://cran.us.r-project.org')

$$ LANGUAGE plr;"

dbSendQuery(conn,query)

dbGetQuery(conn,"select test_plr()")