Какие решения для ошибки RGEOSBinPredFunc() или line2route при использовании stplanr в R?
Я пытаюсь построить карту плотности потока использования велосипеда, используя пакет stplanr. Сетевые данные были получены из OSM, а данные о найме получены из портала данных Nice Bike. Мой рабочий процесс включает в себя агрегацию поездок, настройку пространственной среды и извлечение выборки данных проката перед масштабированием.
Этот кусок кода:
r_truk = line2route(l_truk, route_fun = overline(network, attri = data))
возвращает ошибку ниже:
Error in RGEOSBinPredFunc(spgeom1, spgeom2, byid, func) :
rgeos_binpredfunc_prepared: maximum returned dense matrix size exceeded
Насколько я понимаю, это может быть проблема с памятью. Сетевые данные 70 Мб с 38952 отдельными ссылками.
Вот мой полный код
#create desire lines
library(sp)
library(stplanr)
library(maptools)
library(rgdal)
library(tmap)
setwd("D:\\Bike Share Analysis\\Nice_ride_data_2015_season\\Nice_ride_data_2015_season\\location_data")
cents <- readOGR(dsn = ".", layer = "location_sf") # this file was generated by converting the original location into a shapefile
setwd("D:\\Bike Share Analysis\\MN data\\minneapolis-saint-paul_minnesota.imposm-shapefiles")
network <- readOGR(dsn = ".", layer = "minneapolis-saint-paul-city-center-roads")
setwd("D:\\Bike Share Analysis\\Nice_ride_data_2015_season\\Nice_ride_data_2015_season")
bike_share_hires <- read.csv("Nice_ride_trip_history_2015_season.csv", sep = ",", header = T)
bike_share_hires$hire <- 1 # add a number to aggregate
flow <- aggregate(hire ~ End.station.number + Start.station.number, data = bike_share_hires, FUN = sum)
ind <- which(with( flow, End.station.number == "NRHQ" | Start.station.number == "NRHQ" )) # remove NRHQ bc no coordinates for location
ind # make sure
f <- flow[ -ind, ] # remove from flow
#create full and sample set
flow <- f # reestablish flow file
flow_truk <- flow[1:30,] # sample data to test
#test viewer
tmap_mode("view")
qtm(cents, symbols.size = .25)
#sample run
flow_single_line_truk = flow_truk[4,] # select only the first line
desire_line_single_truk = od2line(flow = flow_single_line_truk, zones = cents)
qtm(desire_line_single_truk, lines.list = 5)
l_truk = od2line(flow = flow_truk, zones = cents)
# remove 'internal flows'
sel = l_truk$Start.station.number == l_truk$End.station.number
l_truk = l_truk[!sel, ]
qtm(l_truk)
tm_shape(l_truk) + tm_lines(scale = 1, col = "hire", alpha = .9, style = "jenks")
curl::has_internet()
r_truk = line2route(l_truk, route_fun = overline(network, attri = data))
#this is where the problem occurs
Если это проблема с памятью, мне интересно, какие решения я должен рассмотреть? Если нет, может ли кто-то дать представление.
Пожалуйста, Даниэль