Questions tagged [geosphere]

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

170 questions
0
votes
1 answer

Error: Assigned data `distHaversine(dtrav)` must be compatible with existing data

I'm just trying to calculate distance travelled using longitude/latitude points. I have 2983223 rows of data. I keep getting this error and my distance column repeats the same value throughout the df. library(geosphere) dtrav <-…
clevr2k
  • 3
  • 1
0
votes
1 answer

Interpolating data using the package move: How to create a movestack object?

I have just started using R for my masters thesis project, and i am trying to interpolate the sampling rate for my penguin tracking data using the package move. However when trying to create a movestack object i get this error: Error in…
Courtney
  • 47
  • 6
0
votes
1 answer

R error: Wrong length for a vector, should be 2 while using Geosphere package

I am trying to analyze avg distance between two locations to come with an acceptable cutoff for auto approval of traveled distance. I have tied referring to (geosphere distHaversine() & dplyr - error wrong length for vector, should be 2) & (Getting…
am_2190
  • 1
  • 1
0
votes
2 answers

Calculate the distance between 2 coordinates in the same row in R

I have a data frame [df] like this: df<-structure(list( Latitude = c(-23.8, -23.8, -23.9, -23.9), Longitude = c(-49.6, -49.3, -49.4, -49.8), Latitude1 = c(-23.4, -23.7, -23.4, -23.8), …
dloudtrain
  • 301
  • 2
  • 9
0
votes
0 answers

Create centroid tag within a radius for longitude-latitude data in R

I have longitude-latitude data (220000 observation [duplicates included]) and I want to create two new columns defining the number of points within 5km and 10 km radius. My problem is the vector size, meaning that the algorithm does not run for…
0
votes
1 answer

Compute geodesic distances in R for all rows in data frame

I have a data frame of the form lon1 lat1 lon2 lat2 ... ... ... ... ... ... ... ... representing coordinates of pairs of points. How do I do to calculate the geodesic distance between the pairs in a new column? There is the package…
mathology
  • 147
  • 4
0
votes
0 answers

Calculate geographical distance between points within groups (using ifelse statement)

Using R, I've been trying to use the distHaversine function to calculate the geographic distance between individuals sampled from different regions, however with the examples online I haven't been successful yet. My main issue is that I can't figure…
0
votes
0 answers

Distance between zip codes: Running into a 500 vector limit calling given function

In a helpful post from Dave2e back in 2019, I'm using his suggested function as described here: R Find the Distance between Two US Zipcode columns Dave's solution works great for the OP. My issue is: When I feed the function more than 500 rows of…
user5509057
  • 159
  • 6
0
votes
0 answers

calculating the distance of a list of coordinates to a reference coordinate using R

I have an xlsx file which has 200 restaurants and 1 warehouse location with their coordinates in latitude and longitude. I want to calculate the distance from the warehouse to the restaurants using R. And rank them from shortes to longes in…
0
votes
1 answer

Matrix of geospatial distance between each actor in a data frame?

Good evening, I am trying to calculate the distance from each row in a data frame to the other rows. My data looks like this: gps <- data.frame(company = c("Jonas","Felix","Maria","Anna"), longitude = c(42.33606636507468,…
SteffenT
  • 119
  • 6
0
votes
1 answer

Crossing two sets of coordinates in order to calculate minimum distance? (tidyr geosphere R)

I have a set of 2,220 nest coordinates (var1) and another set of 26 landmark coordinates (var2) in the same bounded area. I want to find the distance between each of the 2,224 coordinates to every point in the set of 26 in order to create a new data…
Zoe W
  • 3
  • 1
0
votes
0 answers

Can not use centroid() function with longitude more than 360

I want to compute the center coordinate in a group of coordinate but failed. I use centroid() function from geosphere package. The error says: Error in .pointsToMatrix(x, poly = TRUE) : longitude > 360 centroid(shp_df_32[, c('long', 'lat')]) My…
zhiwei li
  • 1,635
  • 8
  • 26
0
votes
1 answer

Generate random GPS Points on a Radius

Is there a way to generate random Points between 2 points on a given Radius? As you can see in my drawing: Point A and Point B is known. Also r is known. Im looking for a way to generate points 1,2,3 between G and F. I don't have points G and F. Its…
Andreas
  • 397
  • 4
  • 18
  • 37
0
votes
1 answer

Remove segments of spatial lines based on different conditions

I am trying to calculate an exposure index of the coastline. I have created lines every 5 degrees around a coastal point. I have erased the parts of the lines that intersect over land. However, it creates line segments that I do not want. I need…
N.Senior
  • 25
  • 1
  • 4
0
votes
1 answer

Finding distance between lat-long coordiantes taking a long time R

I currently have a dataframe (lang.py) in which I have pairs of latitude and longitude coordinates. I'm using the distHaversine() function from the geosphere package to do so. This is a sample of my data (which has 25200 rows): Originally I…
Angie
  • 183
  • 3
  • 13