Questions tagged [geosphere]

An R package to calculate the distances and related measures for angular (longitude/latitude) locations

170 questions
0
votes
1 answer

Using sp (spatial package) from my own package results in error: could not find function

I'm developing my first package - well, actually I'm packaging some existing code - in RStudio. I've marked up all the comments with roxygen2 and this has generated a correct NAMESPACE file which…
Michael Henry
  • 599
  • 2
  • 4
  • 17
-1
votes
1 answer

Still getting "Wrong length for a vector, should be 2" error even if using rowwise()

I'm trying to add a "distance" column to a huge (near 6 million rows) dataframe with coordinate information as start_lng, start_lat, end_lng, end_lat columns. I have tried the following: trips$distance <- distm(c(trips$start_lng, trips$start_lat),…
bsiq
  • 3
  • 1
-1
votes
1 answer

R: divide a given Box into X amount of new boxes with given diagonal

I have a Bbox of Germany with coordinates (lon,lat): g_bbox<-c(xmin=5.98865807458, ymin=47.3024876979, xmax=15.0169958839, ymax=54.983104153) I would like to divide the bbox in (x) amount of bboxes with a diagonal of 50 km each. The length of…
Andreas
  • 397
  • 4
  • 18
  • 37
-1
votes
1 answer

I have 2 dataframes with latitude and longitude in each. I want to find the 5 nearest points from df2 for each point in df1

I tried a row by row approach, like this: library(geosphere) best <- 1000000 for ( var1 in df1 ) { findpoint <- c(df1$longitude[var1], df1$latitude[var1]) for ( var2 in df2 ) { basepoint <- c(df2$longitude[var2],…
-1
votes
2 answers

Getting centre of multiple coordinates in R

I have a data frame with 'lat', 'lon' values such as: index lat lon ------- ----------- ----------- 1 51.513393 -0.115650 2 51.513428 -0.115461 3 51.513428 -0.115462 4 51.513428 …
Falco
  • 61
  • 7
1 2 3
11
12