I have a geopackage containing millions of traffic points as well as a highway zone layer. I would like to extract points inside the highway zones within a R-script.
It is possible to query the attribute data using the library(RSQLite) and dbGetQuery but it seems like the spatial extensions are not available. I'm probably attempting something that is better in another way. Below is a query retrieving data that works and a simple query to replicate the error I receive with any geometry functions.
library(RSQLite)
library(dbplyr)
library(sqldf)
#Connect to geopackage
con <- dbConnect(RSQLite::SQLite(), dbname = "Traffic_data.gpkg",
loadable.extensions = TRUE)
#Select friday traffic
Traffic_Friday <- dbGetQuery(con, "SELECT*
FROM Traffic_data_points
WHERE Day_ = 'Friday' ;")
#But if I include ST_Within:
Traffic_Friday <- dbGetQuery(con, "SELECT*
FROM Traffic_data_points as tp, highway_buf as hb
WHERE tp.Day_ = 'Friday' and ST_Within(tp.geom, hb.geom) ;")
I get this error: Error in result_create(conn@ptr, statement) : no such function: ST_Within. It is the same with all the geometry functions
Is it possible to do something like this?