An R package to calculate the distances and related measures for angular (longitude/latitude) locations
Questions tagged [geosphere]
170 questions
0
votes
0 answers
Given the lat long of the centre of a rectangle, how do you get the lat long of the bottom left corner of the rectangle
I have the latitude and longitude of a point. This point is in the centre of a rectangle that is 2miles wide and 8 miles long. The rectangle has an azimuth (angle from north) of 35degs. How do I get the latitude and longitude of the bottom left…

Andrew
- 1
- 1
0
votes
1 answer
Getting distance between vectors of longitude and latitude points
I have a data set that looks like this:
structure(list(Date2 = structure(c(18428, 18438, 18428, 18438,
18428, 18438, 18428, 18438, 18428, 18438, 18428, 18438, 18428,
18438, 18428, 18438, 18428, 18438, 18428, 18438, 18428, 18438,
18428, 18438,…

David Smith
- 305
- 1
- 8
0
votes
1 answer
Calculating distance with geosphere::distGeo() within dyplr::mutate()
There is a data frame of about 240e6 rows with combinations of coordinate points between pseudonym and pseudonym2 (long, lat).
It looks like the following:
geo <- data.frame(
pseudonym = c("aa", "bb", "cc"),
long_pseudonym = c(9.37, 7.37,…

poetspie
- 73
- 7
0
votes
2 answers
Using loop to calculate bearings over a list
My goal is to apply the geosphere::bearing function to a very large data frame,
yet because the data frame concerns multiple individuals, I split it using the purrr package and split function.
I have seen the use of 'lists' and 'forloops' in the…

Beardedant
- 134
- 8
0
votes
1 answer
R terra create spatraster of day lengths for a year
The length of daylight at a particular latitude can be found with the daylength function from library(geosphere). The day length varies by the day of the year. Here's the function daylength(lat, doy). I'd like to generate a 1/2 degree spatraster…

JerryN
- 2,356
- 1
- 15
- 49
0
votes
1 answer
Substract geographic distances from previous row by group using dplyr and geosphere
I have a dataframe like this.
df <- data.frame(
id = c(rep("A", 5), rep("B", 5)),
date = as.Date(as.Date("2022-6-1"):as.Date("2022-6-10"), origin="1970-01-01"),
lon = 101:110,
lat = 1:10
)
> df
id date lon lat
1 A 2022-06-01…

TKH_9
- 105
- 1
- 7
0
votes
0 answers
Finding the Distance between two geodetic points in R
I have a dataframe with the following columns in it already:
start_lat, start_long, end_lat, end_long.
I need to find the distance between the start/end points in each row. So far, this is what I…

GatorAdmiral03
- 41
- 5
0
votes
0 answers
Using greatCircle function to create a trade map in R
I am using greatCircle {geosphere} function to create a map. I am able to run the code and get the desired connecting lines across the locations. But additionally I am getting an arbitrary straight line in the middle of the map. I am not able to…

betahat
- 1
- 1
0
votes
2 answers
Calculating distance between all locations to first location, by group
I have GPS locations from several seabird tracks, each starting from colony x. Therefore the individual tracks all have similar first locations. For each track, I would like to calculate the beeline distance between each GPS location and either (a)…

user303287
- 131
- 5
0
votes
0 answers
Calculating Distance in R using geosphere
library(geosphere)
distm(c(lon1, lat1), c(lon2, lat2), fun = distHaversine)
Just wondering that the code above will be calculated based on the shortest distance between these two points instead of the actual distance.
If possible is there any way…
0
votes
1 answer
Calculate minimum distance between GPS points using geosphere gives inaccuate values
I am trying to calculate the mean distance between nearest neighbor of a series of GPS points in R. I found two codes to get the values. But it doesn't appear to give the correct distance in meters. When I check against Google Maps, its' way off.
I…

Kyle Finn
- 29
- 5
0
votes
1 answer
How do I loop a specific function from a package in r?
I have list of dates like this.
OnlyDates
[1] "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22" "2018-01-22"
[353] "2018-09-25" "2018-09-25" "2018-09-25" "2018-09-25"…

Leo R
- 3
- 1
0
votes
0 answers
The difference in results when calculating distance with Python haver and R distHaversine
When calculating the distance between two locations with Python and R, I get different results. Python seems to be accurate
Python
import haversine as hs
hs.haversine((41.8777, -87.6353), (41.8915, -87.6268)) # 1.688136…

rsolo__
- 19
- 9
0
votes
1 answer
Plotting Jaccard Index against spatial data (lat-long)
I am trying to find a way to plot a matrix (In this case a matrix with jaccard indices) against spatial distances (I have latitude and longitude data). I have been told to use the "geosphere" package but I haven't been able to fully understand how…

FrankThe Cat
- 21
- 2
0
votes
0 answers
how do I find neighbouring lat long point in kilometer or meter?
I have calculated the nearest location between two points based on the given latitude and longitude using geosphere. The issue I have is the distance is not in kilometers or meters. How can I get the calculated distance in KM or M?
my original…

F H
- 43
- 5