latitude longitude - assign values to a big matrix in R -



latitude longitude - assign values to a big matrix in R -

i have matrix object, named location, 3 columns(id, latitude, logitude) , 18,289 rows:

# id latitude longitude # 320503 31.29530 120.5735 # 310104 31.18852 121.4365 # 310115 31.22152 121.5444 # 110105 39.92147 116.4431

i want calculate haversine distance between each id. in bundle geosphere function distm() can create symmetric distance matrix, dimension 18289 18289. however, r reported error cannot allocate vector of size 2.5 gb.

similarly, ff package,

data.distance.ff <- ff(0, dim = c(18289, 18289))

produces no errors, when assign values ff matrix, r produces errors come again.

data.distance.ff[1:18289, 1:18289] <- distm(location[, 2:3]

error: cannot allocate vector of size 2.5 gb in addition: warning messages: 1: in matrix(0, ncol = n, nrow = n) : reached total allocation of 2047mb: see help(memory.size) 2: in matrix(0, ncol = n, nrow = n) : reached total allocation of 2047mb: see help(memory.size) 3: in matrix(0, ncol = n, nrow = n) : reached total allocation of 2047mb: see help(memory.size) 4: in matrix(0, ncol = n, nrow = n) : reached total allocation of 2047mb: see help(memory.size)

i can verify error with:

data.distance.ff[1:10000, 1:10000] <- distm(location[1:10000, 2:3]

and error:

error: cannot allocate vector of size 772.1 mb.

my questions are:

is code assigning values ff matrix object wrong? should using special assign values ff object instead? canff objects handle storage requirement? can utilize method calculate distance using apply function not involve loops? know function distm() produces matrix twice big needed because symmetric. are there other methods handling big data? bigmemory bundle not appear work on windows computer.

r latitude-longitude apply ff

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -