Questions tagged [geosphere]

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

170 questions
2
votes
1 answer

Wrong area calculation with geosphere:: areaPolygon?

I have used geosphere::areaPolygon() with success many times but now I have encountered an issue. I have a polygon sp2 containing another polygon sp1. So sp2 should have larger area than sp1. When I calculate each area with areaPolygon(), I get the…
danmich
  • 23
  • 4
2
votes
0 answers

R maps and geosphere: connect cities without crossing international dateline

I found this great tutorial on how to use maps and geosphere to connect points on a map in R using great circles: https://flowingdata.com/2011/05/11/how-to-map-connections-with-great-circles/ Is there a way to make the lines go the other way if they…
user3390169
  • 1,015
  • 1
  • 11
  • 34
1
vote
1 answer

Equivalent of R geosphere::distGeo in Python

I am translating R code to Python. I can't find a function to match the output of R function geosphere::distGeo in Python. I have looked at a lot of answers here and it seems the Python equivalent is geopy.distance.geodesic, but the results don't…
gdevaux
  • 2,308
  • 2
  • 10
  • 19
1
vote
1 answer

Classify a timestamp as occurring before or after a distance limit is reached in R

I have a dataframe consisting of a series of timestamps with lat-lon point locations relating to animal GPS tracking data, grouped into separate trips made by each animal. For each timestamped lat-lon, I also have the distance of the point to the…
1
vote
1 answer

Calculate multiple point distance matrices with dplyr

I know that there is a similar question about that here Calculating geographic distances to data points with dplyr::mutate, but none of the answers really helped me to calculate it correctly. I have something like the following data.frame: dt <-…
helianthus
  • 73
  • 8
1
vote
1 answer

Nearest neighbour for postcodes (Germany)

I have two lists of postcodes for Germany (different length). I need to find the closest postcode neighbour for each one in the first dataframe with respect to the second list. I do have longitutde and latitude information as well. It would be great…
Marco
  • 2,368
  • 6
  • 22
  • 48
1
vote
1 answer

How to create a geometry between two sets of points

I have two sets of points (actually I have many hundreds of pairs of two sets but for example, here's one) that look like this... What I want to do is create a linestring or multilinestring that, when drawn, looks loosely like this... The data…
Dean MacGregor
  • 11,847
  • 9
  • 34
  • 72
1
vote
1 answer

How to calculate the distance between points and a fixed location in R Studio

I have a data frame containing thousands of rows about houses. For each row, there are two columns with the longitude and the latitude of this geographical point. My aim is to calculate the distance of each point to the same fixed point (e.g.…
Arthur Lo
  • 13
  • 3
1
vote
1 answer

Is distm() with distHaversine giving inaccurate results?

I'm confused by this result I'm getting from geosphere::distm(). I compute the distance from a starting point to two points a and b. On Google Maps, I can see that the distance from start to a is greater than the distance from start to b. But the…
Sam Firke
  • 21,571
  • 9
  • 87
  • 105
1
vote
1 answer

Geocoding: Efficient way to find the distance between two sets of locations

I have a set of coordinates of the locations of different individuals, and another set of coordinates of different drop off boxes, for their ballots. I'm trying to find the distance between their residence, and the nearest dropbox. I've attached a…
ab1999
  • 13
  • 2
1
vote
1 answer

How to determine if a point is within a buffer

I am handling a SpatialPointsDataFrame that looks like this: new("SpatialPointsDataFrame", data = structure(list(date = c("01dec2013", "01jul2003", "01nov2008", "01dec2017", "01dec2017", "01dec2003" ), company = c("Shwe Taung", "PetroChina…
nflore
  • 196
  • 1
  • 10
1
vote
0 answers

How to find rhumb line distance without crossing the date line?

Seemingly quite a simple problem, but I just can't get it. Essentially I am trying to plot a bunch of lines of different weights showing international trade flows, via leaflet in R. I tried using great circle approaches but it doesn't give the…
tofd
  • 620
  • 4
  • 11
1
vote
2 answers

Distance between coordinates in dataframe sequentially?

I have a dataframe with lat/lon coordinates which are basically gps signals. I need to calculate the distance between sequential rows to then use in a check to ensure it does't exceed a specific threshold I'm interested in. Here is an example…
Dasr
  • 777
  • 6
  • 16
1
vote
1 answer

How to calculate distance between 2 points with leaflet, geosphere, and R shiny

This is a simplified working representation of my code. I have two collections of locations of points. One is automobiles and the other is dealers. There is a slider of distance in miles. If a user clicks on the dealer location and selects the…
1
vote
1 answer

Mutate when function output has data in two columns (geosphere)

I have animal survey data from transects. Transects are divided into sections. There are lat/lon data for the start/endpoints of some sections but not others, and I want to calculate the start/endpoints for sections where these values are missing.…
sbliss
  • 87
  • 2